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

TypeError in _remove_cached_results_from_failed_fixtures with pytest 5.4 #103

Closed
The-Compiler opened this issue Mar 11, 2020 · 5 comments · Fixed by #104
Closed

TypeError in _remove_cached_results_from_failed_fixtures with pytest 5.4 #103

The-Compiler opened this issue Mar 11, 2020 · 5 comments · Fixed by #104

Comments

@The-Compiler
Copy link
Member

When running the testsuite with pytest master (which is soon going to become pytest 5.4), the tests fail with:

test_rerun_on_module_fixture_with_reruns.py RER
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/florian/proj/pytest/src/_pytest/main.py", line 191, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/florian/proj/pytest/src/_pytest/main.py", line 247, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/manager.py", line 337, in traced_hookexec
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/callers.py", line 52, in from_call
INTERNALERROR>     result = func()
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/manager.py", line 335, in <lambda>
INTERNALERROR>     outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/florian/proj/pytest/src/_pytest/main.py", line 272, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/manager.py", line 337, in traced_hookexec
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/callers.py", line 52, in from_call
INTERNALERROR>     result = func()
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/manager.py", line 335, in <lambda>
INTERNALERROR>     outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pytest_rerunfailures.py", line 194, in pytest_runtest_protocol
INTERNALERROR>     _remove_cached_results_from_failed_fixtures(item)
INTERNALERROR>   File "/home/florian/code/pytest-rerunfailures/.tox/py3-pytest52/lib/python3.8/site-packages/pytest_rerunfailures.py", line 135, in _remove_cached_results_from_failed_fixtures
INTERNALERROR>     result, cache_key, err = getattr(fixture_def, cached_result)
INTERNALERROR> TypeError: cannot unpack non-iterable NoneType object
@icemac
Copy link
Contributor

icemac commented Mar 12, 2020

@The-Compiler Do you have any hints what changed in pytest what could cause the exception?

@The-Compiler
Copy link
Member Author

Looks like pytest 5.4 was released now (I'd really have preferred to wait until this is fixed, but that's another story...).

I bisected this in pytest and it's caused by pytest-dev/pytest@d839686 - the changelog entry is a pretty good hint at what to change.

The first part is trivial:

diff --git pytest_rerunfailures.py pytest_rerunfailures.py
index e46e770..abe890c 100644
--- pytest_rerunfailures.py
+++ pytest_rerunfailures.py
@@ -131,7 +131,7 @@ def _remove_cached_results_from_failed_fixtures(item):
     for fixture_def_str in getattr(fixture_info, 'name2fixturedefs', ()):
         fixture_defs = fixture_info.name2fixturedefs[fixture_def_str]
         for fixture_def in fixture_defs:
-            if hasattr(fixture_def, cached_result):
+            if getattr(fixture_def, cached_result, None):
                 result, cache_key, err = getattr(fixture_def, cached_result)
                 if err:  # Deleting cached results for only failed fixtures
                     delattr(fixture_def, cached_result)

Not sure about the best way to solve the second part, though. Will probably need to parse and check pytest.__version__ if the code should continue working with older versions as well. I'll go to bed now and will be quite busy over the next couple of days, so if someone else wants to pick this up, that'd be great.

@RonnyPfannschmidt
Copy link
Member

I apologise, I missed the comment, else I wouldn't have released

I'll try to sort it out tommorow morning, but I'd appreciate if someone beat me to it

@The-Compiler The-Compiler changed the title TypeError in _remove_cached_results_from_failed_fixtures with pytest master TypeError in _remove_cached_results_from_failed_fixtures with pytest 5.4 Mar 12, 2020
@The-Compiler
Copy link
Member Author

Thanks, GitHub, for closing this automatically for a qutebrowser commit saying "Probably a bad idea before this is fixed: "...

@The-Compiler The-Compiler reopened this Mar 12, 2020
@RonnyPfannschmidt
Copy link
Member

i have a fix almost ready, pr in a few

nicoddemus added a commit to nicoddemus/pytest that referenced this issue Mar 12, 2020
Noticed that the pytest_report_teststatus of reportlog was not properly
handling unknown statuses while taking a look at:

pytest-dev/pytest-rerunfailures#103
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Mar 13, 2020
Noticed that the pytest_report_teststatus of reportlog was not properly
handling unknown statuses while taking a look at:

pytest-dev/pytest-rerunfailures#103
lukeseawalker added a commit to lukeseawalker/aws-parallelcluster that referenced this issue Aug 17, 2020
New version of pytest-xdist (2.0.0) has requirement pytest>=6.0.0

Pytest was pinned to 5.3.5 because of pytest-dev/pytest-rerunfailures#103, that is now fixed.

Signed-off-by: Luca Carrogu <[email protected]>
lukeseawalker added a commit to lukeseawalker/aws-parallelcluster that referenced this issue Aug 17, 2020
New version of pytest-xdist (2.0.0) has requirement pytest>=6.0.0

Pytest was pinned to 5.3.5 because of pytest-dev/pytest-rerunfailures#103, that is now fixed.

Signed-off-by: Luca Carrogu <[email protected]>
lukeseawalker added a commit to lukeseawalker/aws-parallelcluster that referenced this issue Aug 17, 2020
New version of pytest-xdist (2.0.0) has requirement pytest>=6.0.0

Pytest was pinned to 5.3.5 because of pytest-dev/pytest-rerunfailures#103, that is now fixed.

Signed-off-by: Luca Carrogu <[email protected]>
lukeseawalker added a commit to aws/aws-parallelcluster that referenced this issue Aug 17, 2020
New version of pytest-xdist (2.0.0) has requirement pytest>=6.0.0

Pytest was pinned to 5.3.5 because of pytest-dev/pytest-rerunfailures#103, that is now fixed.

Signed-off-by: Luca Carrogu <[email protected]>
lukeseawalker added a commit to aws/aws-parallelcluster that referenced this issue Aug 17, 2020
New version of pytest-xdist (2.0.0) has requirement pytest>=6.0.0

Pytest was pinned to 5.3.5 because of pytest-dev/pytest-rerunfailures#103, that is now fixed.

Signed-off-by: Luca Carrogu <[email protected]>
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

Successfully merging a pull request may close this issue.

3 participants