sih4sing5hong5 added the comment:
I moved the import urlopen inside the patch.
The mock worked.
Thank you for explanations. I understand now.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24855
New submission from sih4sing5hong5:
I also posted in stackoverflow:
http://stackoverflow.com/questions/30978207/python-urlopen-mock-fail
```
from unittest.mock import patch
import urllib
from urllib import request
from urllib.request import urlopen
@patch('urllib.request.urlopen')
def
sih4sing5hong5 added the comment:
It is normal because of __all__ syntax.
By:
https://github.com/testing-cabal/mock/issues/313#issuecomment-130564364
--
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org
sih4sing5hong5 added the comment:
Thank you.
I updated my patch in `VALID_MODULE_NAME.patch`.
--
Added file: http://bugs.python.org/file39789/VALID_MODULE_NAME.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24263
Changes by sih4sing5hong5 ihc...@gmail.com:
Removed file: http://bugs.python.org/file39778/VALID_MODULE_NAME.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24263
sih4sing5hong5 added the comment:
update by adding `except AttributeError:`
--
Added file: http://bugs.python.org/file39794/VALID_MODULE_NAME2.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24263
New submission from sih4sing5hong5:
Because VALID_MODULE_NAME is r'[_a-z]\w*\.py$' in unittest/loader.py.
Using r'[^\W\d]\w*\.py$' insteaded.
--
keywords: +patch
title: Why VALID_MODULE_NAME in unittest/loader.py is r'[_a-z]\w*\.py$' not
r'\w+\.py$' ? - unittest cannot load module
sih4sing5hong5 added the comment:
There is an attached file for examples.
I ran
{{{
cd test_dir
python -m unittest -v
}}}
and got
Ran 1 test in 0.000s
--
Added file: http://bugs.python.org/file39779/test_dir.tar.gz
___
Python tracker rep
sih4sing5hong5 added the comment:
By the way, I ran with Python 3.4.0.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24263
___
___
Python-bugs
Changes by sih4sing5hong5 ihc...@gmail.com:
--
components: Unicode
nosy: ezio.melotti, haypo, sih4sing5hong5
priority: normal
severity: normal
status: open
title: Why VALID_MODULE_NAME in unittest/loader.py is r'[_a-z]\w*\.py$' not
r'\w+\.py$' ?
type: behavior
versions: Python 3.2
10 matches
Mail list logo