New issue 486: `--help` should not fail with an exception on conftest.py errors
/ handle conftest imports more gracefully/meaningful
https://bitbucket.org/hpk42/pytest/issue/486/help-should-not-fail-with-an-exception-on
Daniel Hahler:
I have just installed `pytest` globally and wanted to look at the help options,
but it failed (probably because of me being in the project directory, but
without the virtualenv activated):
There is ../../../conftest.py, which contains an import, which does not work
outside of the virtualenv.
I think py.test should be more helpful, and display its help
options/information nonetheless. It would be nice to get a warning that the
conftest.py failed to get imported/parsed on top.
This warning would be useful in the generic case also: it's hard to tell from
the Traceback that there is some conftest.py issue involved.
Traceback (most recent call last):
File "/usr/local/bin/py.test", line 9, in <module>
load_entry_point('pytest==2.5.2', 'console_scripts',
'py.test')()
File
"/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 19, in main
config = _prepareconfig(args, plugins)
File
"/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 63, in
_prepareconfig
pluginmanager=pluginmanager, args=args)
File "/usr/local/lib/python2.7/dist-packages/_pytest/core.py",
line 377, in __call__
return self._docall(methods, kwargs)
File "/usr/local/lib/python2.7/dist-packages/_pytest/core.py",
line 388, in _docall
res = mc.execute()
File "/usr/local/lib/python2.7/dist-packages/_pytest/core.py",
line 289, in execute
res = method(**kwargs)
File
"/usr/local/lib/python2.7/dist-packages/_pytest/helpconfig.py", line 27, in
pytest_cmdline_parse
config = __multicall__.execute()
File "/usr/local/lib/python2.7/dist-packages/_pytest/core.py",
line 289, in execute
res = method(**kwargs)
File
"/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 618, in
pytest_cmdline_parse
self.parse(args)
File
"/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 711, in parse
self._preparse(args)
File
"/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 691, in
_preparse
args=args, parser=self._parser)
File "/usr/local/lib/python2.7/dist-packages/_pytest/core.py",
line 377, in __call__
return self._docall(methods, kwargs)
File "/usr/local/lib/python2.7/dist-packages/_pytest/core.py",
line 388, in _docall
res = mc.execute()
File "/usr/local/lib/python2.7/dist-packages/_pytest/core.py",
line 289, in execute
res = method(**kwargs)
File
"/usr/local/lib/python2.7/dist-packages/_pytest/capture.py", line 83, in
pytest_load_initial_conftests
return __multicall__.execute()
File "/usr/local/lib/python2.7/dist-packages/_pytest/core.py",
line 289, in execute
res = method(**kwargs)
File
"/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 674, in
pytest_load_initial_conftests
self._conftest.setinitial(args)
File
"/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 490, in
setinitial
self._try_load_conftest(current)
File
"/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 493, in
_try_load_conftest
self._path2confmods[None] =
self.getconftestmodules(anchor)
File
"/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 512, in
getconftestmodules
clist.append(self.importconftest(conftestpath))
File
"/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 538, in
importconftest
self._conftestpath2mod[conftestpath] = mod =
conftestpath.pyimport()
File
"/usr/local/lib/python2.7/dist-packages/py/_path/local.py", line 620, in
pyimport
__import__(modname)
File "…/conftest.py", line 8, in <module>
from selenium import webdriver
ImportError: No module named selenium
_______________________________________________
pytest-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-commit