question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Broken by pytest 5.3.3

See original GitHub issue

I haven’t had time to investigate why, but it seems that the pytest 5.3.3 release broke pytest-lazy-fixture:

Running the basic example from the README

import pytest

@pytest.fixture(params=[1, 2])
def one(request):
    return request.param

@pytest.mark.parametrize('arg1,arg2', [
    ('val1', pytest.lazy_fixture('one')),
])
def test_func(arg1, arg2):
    assert arg2 in [1, 2]

results in the following error:

$ pytest test_lazy_fixture.py 
============================= test session starts ==============================
platform linux -- Python 3.6.9, pytest-5.3.3, py-1.7.0, pluggy-0.12.0
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/yannick/.hypothesis/examples')
rootdir: /home/yannick
plugins: xonsh-0.9.6, lazy-fixture-0.6.2, hypothesis-4.34.0
collected 2 items                                                              

test_lazy_fixture.py EE                                                  [100%]

==================================== ERRORS ====================================
__________________ ERROR at setup of test_func[val1-arg20-1] ___________________
file /home/yannick/test_lazy_fixture.py, line 7
  @pytest.mark.parametrize('arg1,arg2', [
      ('val1', pytest.lazy_fixture('one')),
  ])
  def test_func(arg1, arg2):
file /home/yannick/test_lazy_fixture.py, line 3
  @pytest.fixture(params=[1, 2])
  def one(request):
file /home/yannick/.local/lib/python3.6/site-packages/_pytest/fixtures.py, line 297
  def get_direct_param_fixture_func(request):
E       recursive dependency involving fixture 'one' detected
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, one, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/yannick/.local/lib/python3.6/site-packages/_pytest/fixtures.py:297
__________________ ERROR at setup of test_func[val1-arg20-2] ___________________
file /home/yannick/test_lazy_fixture.py, line 7
  @pytest.mark.parametrize('arg1,arg2', [
      ('val1', pytest.lazy_fixture('one')),
  ])
  def test_func(arg1, arg2):
file /home/yannick/test_lazy_fixture.py, line 3
  @pytest.fixture(params=[1, 2])
  def one(request):
file /home/yannick/.local/lib/python3.6/site-packages/_pytest/fixtures.py, line 297
  def get_direct_param_fixture_func(request):
E       recursive dependency involving fixture 'one' detected
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, one, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/yannick/.local/lib/python3.6/site-packages/_pytest/fixtures.py:297
============================== 2 errors in 0.02s ===============================

If I have time, I’ll have a closer look and report back on my findings.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
bstaleticcommented, Jan 17, 2020

I’ve tried to bisect pytest and it looks like https://github.com/pytest-dev/pytest/commit/99180939febb6ca4b3ff788cf336b065046653f2 broke pytest-lazy-fixture. This commit exists in 5.3.3 but not in 5.3.2.

1reaction
taioncommented, Jan 21, 2020

It’s still worth potentially sorting through the root issue – I don’t think the upstream change was buggy per se.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pytest 5.3.3: slow or crashing tests · Issue #6492 - GitHub
Autouse and parameterization results in fixtures not being torn down, or even being torn down out of order #6436: :class: FixtureDef <_pytest.
Read more >
Changelog — pytest documentation
Backward incompatible (breaking) changes will only be introduced in major versions with advance notice in the Deprecations ... pytest 5.3.3 (2020-01-16).
Read more >
pytest-rerunfailures - PyPI
pytest plugin to re-run tests to eliminate flaky failures.
Read more >
Changelog — pytest documentation - Read the Docs
Backward incompatible (breaking) changes will only be introduced in major versions with advance notice in the Deprecations section of releases.
Read more >
pytest Documentation - Read the Docs
2.18 How to use unittest-based tests with pytest . ... functions and some third-party libraries used by pytest might break pytest itself,.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found