Created
August 28, 2018 09:26
-
-
Save kohr-h/0899f6e87262de1f16e409e46f46c1e2 to your computer and use it in GitHub Desktop.
pytest plugin UsageError backtrace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...]\_pytest\config\__init__.py:518: UsageError | |
____ ERROR at setup of [doctest] odl.util.utility.NumpyRandomSeed.__init__ ____ | |
self = <CallInfo when='setup' exception: Plugin specs must be a ','-separated string or a list/tuple of strings for plugin names. Given: <module 'odl.util.pytest_plugins' from '[...]\\odl\\util\\pytest_plugins.py'>> | |
func = <function call_runtest_hook.<locals>.<lambda> at 0x00000000054AB620> | |
when = 'setup', treat_keyboard_interrupt_as_exception = False | |
def __init__(self, func, when, treat_keyboard_interrupt_as_exception=False): | |
#: context of invocation: one of "setup", "call", | |
#: "teardown", "memocollect" | |
self.when = when | |
self.start = time() | |
try: | |
> self.result = func() | |
[...]\_pytest\runner.py:201: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
> lambda: ihook(item=item, **kwds), | |
when=when, | |
treat_keyboard_interrupt_as_exception=item.config.getvalue("usepdb"), | |
) | |
[...]\_pytest\runner.py:183: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <_HookCaller 'pytest_runtest_setup'>, args = () | |
kwargs = {'item': <DoctestItem 'odl.util.utility.NumpyRandomSeed.__init__'>} | |
notincall = set() | |
def __call__(self, *args, **kwargs): | |
if args: | |
raise TypeError("hook calling supports only keyword arguments") | |
assert not self.is_historic() | |
if self.argnames: | |
notincall = set(self.argnames) - set(['__multicall__']) - set( | |
kwargs.keys()) | |
if notincall: | |
warnings.warn( | |
"Argument(s) {} which are declared in the hookspec " | |
"can not be found in this hook call" | |
.format(tuple(notincall)), | |
stacklevel=2, | |
) | |
> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs) | |
[...]\pluggy\hooks.py:258: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <_pytest.config.PytestPluginManager object at 0x0000000002B84240> | |
hook = <_HookCaller 'pytest_runtest_setup'> | |
methods = [<HookImpl plugin_name='nose', plugin=<module '_pytest.nose' from '[...]\\lib\\si...375048>>, <HookImpl plugin_name='logging-plugin', plugin=<_pytest.logging.LoggingPlugin object at 0x0000000005394CF8>>] | |
kwargs = {'item': <DoctestItem 'odl.util.utility.NumpyRandomSeed.__init__'>} | |
def _hookexec(self, hook, methods, kwargs): | |
# called from all hookcaller instances. | |
# enable_tracing will set its own wrapping function at self._inner_hookexec | |
> return self._inner_hookexec(hook, methods, kwargs) | |
[...]\pluggy\manager.py:67: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
hook = <_HookCaller 'pytest_runtest_setup'> | |
methods = [<HookImpl plugin_name='nose', plugin=<module '_pytest.nose' from '[...]\\lib\\si...375048>>, <HookImpl plugin_name='logging-plugin', plugin=<_pytest.logging.LoggingPlugin object at 0x0000000005394CF8>>] | |
kwargs = {'item': <DoctestItem 'odl.util.utility.NumpyRandomSeed.__init__'>} | |
self._inner_hookexec = lambda hook, methods, kwargs: \ | |
hook.multicall( | |
methods, kwargs, | |
> firstresult=hook.spec_opts.get('firstresult'), | |
) | |
[...]\pluggy\manager.py:61: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
hook_impls = [<HookImpl plugin_name='nose', plugin=<module '_pytest.nose' from '[...]\\lib\\si...375048>>, <HookImpl plugin_name='logging-plugin', plugin=<_pytest.logging.LoggingPlugin object at 0x0000000005394CF8>>] | |
caller_kwargs = {'item': <DoctestItem 'odl.util.utility.NumpyRandomSeed.__init__'>} | |
firstresult = False | |
def _multicall(hook_impls, caller_kwargs, firstresult=False): | |
"""Execute a call into multiple python functions/methods and return the | |
result(s). | |
``caller_kwargs`` comes from _HookCaller.__call__(). | |
""" | |
__tracebackhide__ = True | |
results = [] | |
excinfo = None | |
try: # run impl and wrapper setup functions in a loop | |
teardowns = [] | |
try: | |
for hook_impl in reversed(hook_impls): | |
try: | |
args = [caller_kwargs[argname] for argname in hook_impl.argnames] | |
except KeyError: | |
for argname in hook_impl.argnames: | |
if argname not in caller_kwargs: | |
raise HookCallError( | |
"hook call must provide argument %r" % (argname,)) | |
if hook_impl.hookwrapper: | |
try: | |
gen = hook_impl.function(*args) | |
next(gen) # first yield | |
teardowns.append(gen) | |
except StopIteration: | |
_raise_wrapfail(gen, "did not yield") | |
else: | |
res = hook_impl.function(*args) | |
if res is not None: | |
results.append(res) | |
if firstresult: # halt further impl calls | |
break | |
except BaseException: | |
excinfo = sys.exc_info() | |
finally: | |
if firstresult: # first result hooks return a single value | |
outcome = _Result(results[0] if results else None, excinfo) | |
else: | |
outcome = _Result(results, excinfo) | |
# run all wrapper post-yield blocks | |
for gen in reversed(teardowns): | |
try: | |
gen.send(outcome) | |
_raise_wrapfail(gen, "has second yield") | |
except StopIteration: | |
pass | |
> return outcome.get_result() | |
[...]\pluggy\callers.py:201: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <pluggy.callers._Result object at 0x00000000057BE358> | |
def get_result(self): | |
"""Get the result(s) for this hook call. | |
If the hook was marked as a ``firstresult`` only a single value | |
will be returned otherwise a list of results. | |
""" | |
__tracebackhide__ = True | |
if self._excinfo is None: | |
return self._result | |
else: | |
ex = self._excinfo | |
if _py3: | |
> raise ex[1].with_traceback(ex[2]) | |
[...]\pluggy\callers.py:76: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
hook_impls = [<HookImpl plugin_name='nose', plugin=<module '_pytest.nose' from '[...]\\lib\\si...375048>>, <HookImpl plugin_name='logging-plugin', plugin=<_pytest.logging.LoggingPlugin object at 0x0000000005394CF8>>] | |
caller_kwargs = {'item': <DoctestItem 'odl.util.utility.NumpyRandomSeed.__init__'>} | |
firstresult = False | |
def _multicall(hook_impls, caller_kwargs, firstresult=False): | |
"""Execute a call into multiple python functions/methods and return the | |
result(s). | |
``caller_kwargs`` comes from _HookCaller.__call__(). | |
""" | |
__tracebackhide__ = True | |
results = [] | |
excinfo = None | |
try: # run impl and wrapper setup functions in a loop | |
teardowns = [] | |
try: | |
for hook_impl in reversed(hook_impls): | |
try: | |
args = [caller_kwargs[argname] for argname in hook_impl.argnames] | |
except KeyError: | |
for argname in hook_impl.argnames: | |
if argname not in caller_kwargs: | |
raise HookCallError( | |
"hook call must provide argument %r" % (argname,)) | |
if hook_impl.hookwrapper: | |
try: | |
gen = hook_impl.function(*args) | |
next(gen) # first yield | |
teardowns.append(gen) | |
except StopIteration: | |
_raise_wrapfail(gen, "did not yield") | |
else: | |
> res = hook_impl.function(*args) | |
[...]\pluggy\callers.py:180: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
item = <DoctestItem 'odl.util.utility.NumpyRandomSeed.__init__'> | |
def pytest_runtest_setup(item): | |
_update_current_test_var(item, "setup") | |
> item.session._setupstate.prepare(item) | |
[...]\_pytest\runner.py:104: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <_pytest.runner.SetupState object at 0x0000000005394550> | |
colitem = <DoctestItem 'odl.util.utility.NumpyRandomSeed.__init__'> | |
def prepare(self, colitem): | |
""" setup objects along the collector chain to the test-method | |
and teardown previously setup objects.""" | |
needed_collectors = colitem.listchain() | |
self._teardown_towards(needed_collectors) | |
# check if the last collection node has raised an error | |
for col in self.stack: | |
if hasattr(col, "_prepare_exc"): | |
> six.reraise(*col._prepare_exc) | |
[...]\_pytest\runner.py:366: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
tp = <class '_pytest.config.exceptions.UsageError'>, value = None, tb = None | |
def reraise(tp, value, tb=None): | |
try: | |
if value is None: | |
value = tp() | |
if value.__traceback__ is not tb: | |
> raise value.with_traceback(tb) | |
[...]\six.py:692: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <_pytest.runner.SetupState object at 0x0000000005394550> | |
colitem = <DoctestItem 'odl.util.normalize.normalized_axes_tuple'> | |
def prepare(self, colitem): | |
""" setup objects along the collector chain to the test-method | |
and teardown previously setup objects.""" | |
needed_collectors = colitem.listchain() | |
self._teardown_towards(needed_collectors) | |
# check if the last collection node has raised an error | |
for col in self.stack: | |
if hasattr(col, "_prepare_exc"): | |
six.reraise(*col._prepare_exc) | |
for col in needed_collectors[len(self.stack) :]: | |
self.stack.append(col) | |
try: | |
> col.setup() | |
[...]\_pytest\runner.py:370: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Package '[...]\\odl\\util'> | |
def setup(self): | |
> setup_module = _get_xunit_setup_teardown(self.obj, "setUpModule") | |
[...]\_pytest\python.py:527: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Package '[...]\\odl\\util'> | |
def fget(self): | |
obj = getattr(self, "_obj", None) | |
if obj is None: | |
> self._obj = obj = self._getobj() | |
[...]\_pytest\python.py:273: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Package '[...]\\odl\\util'> | |
def _getobj(self): | |
> return self._importtestmodule() | |
[...]\_pytest\python.py:470: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Package '[...]\\odl\\util'> | |
def _importtestmodule(self): | |
# we assume we are only called once per module | |
importmode = self.config.getoption("--import-mode") | |
try: | |
mod = self.fspath.pyimport(ensuresyspath=importmode) | |
except SyntaxError: | |
raise self.CollectError( | |
_pytest._code.ExceptionInfo().getrepr(style="short") | |
) | |
except self.fspath.ImportMismatchError: | |
e = sys.exc_info()[1] | |
raise self.CollectError( | |
"import file mismatch:\n" | |
"imported module %r has this __file__ attribute:\n" | |
" %s\n" | |
"which is not the same as the test file we want to collect:\n" | |
" %s\n" | |
"HINT: remove __pycache__ / .pyc files and/or use a " | |
"unique basename for your test file modules" % e.args | |
) | |
except ImportError: | |
from _pytest._code.code import ExceptionInfo | |
exc_info = ExceptionInfo() | |
if self.config.getoption("verbose") < 2: | |
exc_info.traceback = exc_info.traceback.filter(filter_traceback) | |
exc_repr = ( | |
exc_info.getrepr(style="short") | |
if exc_info.traceback | |
else exc_info.exconly() | |
) | |
formatted_tb = safe_str(exc_repr) | |
raise self.CollectError( | |
"ImportError while importing test module '{fspath}'.\n" | |
"Hint: make sure your test modules/packages have valid Python names.\n" | |
"Traceback:\n" | |
"{traceback}".format(fspath=self.fspath, traceback=formatted_tb) | |
) | |
except _pytest.runner.Skipped as e: | |
if e.allow_module_level: | |
raise | |
raise self.CollectError( | |
"Using pytest.skip outside of a test is not allowed. " | |
"To decorate a test function, use the @pytest.mark.skip " | |
"or @pytest.mark.skipif decorators instead, and to skip a " | |
"module use `pytestmark = pytest.mark.{skip,skipif}." | |
) | |
> self.config.pluginmanager.consider_module(mod) | |
[...]\_pytest\python.py:523: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <_pytest.config.PytestPluginManager object at 0x0000000002B84240> | |
mod = <module 'odl.util' from '[...]\\odl\\util\\__init__.py'> | |
def consider_module(self, mod): | |
> self._import_plugin_specs(getattr(mod, "pytest_plugins", [])) | |
[...]\_pytest\config\__init__.py:462: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <_pytest.config.PytestPluginManager object at 0x0000000002B84240> | |
spec = <module 'odl.util.pytest_plugins' from '[...]\\odl\\util\\pytest_plugins.py'> | |
def _import_plugin_specs(self, spec): | |
> plugins = _get_plugin_specs_as_list(spec) | |
[...]\_pytest\config\__init__.py:465: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
specs = <module 'odl.util.pytest_plugins' from '[...]\\odl\\util\\pytest_plugins.py'> | |
def _get_plugin_specs_as_list(specs): | |
""" | |
Parses a list of "plugin specs" and returns a list of plugin names. | |
Plugin specs can be given as a list of strings separated by "," or already as a list/tuple in | |
which case it is returned as a list. Specs can also be `None` in which case an | |
empty list is returned. | |
""" | |
if specs is not None: | |
if isinstance(specs, str): | |
specs = specs.split(",") if specs else [] | |
if not isinstance(specs, (list, tuple)): | |
raise UsageError( | |
"Plugin specs must be a ','-separated string or a " | |
> "list/tuple of strings for plugin names. Given: %r" % specs | |
) | |
E _pytest.config.exceptions.UsageError: Plugin specs must be a ','-separated string or a list/tuple of strings for plugin names. Given: <module 'odl.util.pytest_plugins' from '[...]\\odl\\util\\pytest_plugins.py'> | |
[...]\_pytest\config\__init__.py:518: UsageError | |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! KeyboardInterrupt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
[...]\_pytest\_code\source.py:341: KeyboardInterrupt | |
(to show a full traceback on KeyboardInterrupt use --fulltrace) | |
========================== 12 error in 5.32 seconds =========================== | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment