pytest-dev / pytest-bdd

BDD library for the pytest runner
https://pytest-bdd.readthedocs.io/en/latest/
MIT License
1.31k stars 221 forks source link

error when using with --testmon #362

Closed jnoortheen closed 11 months ago

jnoortheen commented 4 years ago

I have bdd tests and trying to use pytest --testmon from https://pypi.org/project/pytest-testmon/

But it fails with

 ❯ pytest --testmon                                                                                                                                  
Exit: The stored data file /home/noor/src/src/py/divisible/yolo/.testmondata version (4) is not compatible with current version (6). You must delete the stored data to continue.
Traceback (most recent call last):
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/bin/pytest", line 10, in <module>
    sys.exit(main())
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/_pytest/config/__init__.py", line 124, in main
    ret = config.hook.pytest_cmdline_main(
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/_pytest/main.py", line 240, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/_pytest/main.py", line 235, in wrap_session
    config._ensure_unconfigure()
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/_pytest/config/__init__.py", line 825, in _ensure_unconfigure
    self.hook.pytest_unconfigure(config=self)
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/noor/.virtualenvs/yolo-fc-KERI9mRf-py3.8/lib/python3.8/site-packages/pytest_bdd/plugin.py", line 51, in pytest_unconfigure
    CONFIG_STACK.pop()
IndexError: pop from empty list

Versions

  1. pytest - 5.4.2
  2. bdd - 3.3.0
  3. testmon - 1.0.2
n3world commented 1 year ago

The issue is that pytest does not guarantee that when pytest_unconfigure is called that pytest_configure was already called. This can happen if another plugin or something causes pytest to exit during the configure phase but before the bdd pytest_configure runs.

n3world commented 1 year ago

I think this can be closed now

youtux commented 11 months ago

Fixed in https://github.com/pytest-dev/pytest-bdd/pull/641

youtux commented 11 months ago

I just released version 7.0.1 with the fix