Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when using with --testmon #362

Closed
jnoortheen opened this issue May 21, 2020 · 4 comments
Closed

error when using with --testmon #362

jnoortheen opened this issue May 21, 2020 · 4 comments

Comments

@jnoortheen
Copy link

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
Copy link
Contributor

n3world commented Oct 23, 2023

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 added a commit to n3world/pytest-bdd that referenced this issue Oct 23, 2023
`pytest_unconfigure` can be called even if `pytest_configure` was not.
In order to avoid errors during unconfigure only perform the unconfigure
if the configure was performed. Add a counter which is incremented
before configure to track the number of times pytest started
initialization so that the config is not popped early from the stack.
n3world added a commit to n3world/pytest-bdd that referenced this issue Oct 31, 2023
`pytest_unconfigure` can be called even if `pytest_configure` was not.
In order to avoid errors during unconfigure only perform the unconfigure
if the configure was performed. Add a counter which is incremented
before configure to track the number of times pytest started
initialization so that the config is not popped early from the stack.
n3world added a commit to n3world/pytest-bdd that referenced this issue Oct 31, 2023
`pytest_unconfigure` can be called even if `pytest_configure` was not.
In order to avoid errors during unconfigure only perform the unconfigure
if the configure was performed. Add a counter which is incremented
before configure to track the number of times pytest started
initialization so that the config is not popped early from the stack.
youtux added a commit that referenced this issue Nov 11, 2023
Issue #362: Only unconfigure if configured
@n3world
Copy link
Contributor

n3world commented Nov 14, 2023

I think this can be closed now

@youtux
Copy link
Contributor

youtux commented Dec 2, 2023

Fixed in #641

@youtux youtux closed this as completed Dec 2, 2023
@youtux
Copy link
Contributor

youtux commented Dec 2, 2023

I just released version 7.0.1 with the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants