Skip to content

Duplicate available fixtures cause sorting logic to fail #1651

@martinpelikan

Description

@martinpelikan

When running py.test --fixtures It looks like the fixture sorting logic found here fails when duplicate entries are encountered in the available list. The problem is probably rooted in why there are duplicate entries in the first place, but a quick fix might be to sort only on the relevant keys or deduplicate the fixtures. I'm running into this in my tox environment (scoped to running python3.4) - the same tests and command runs on my base Arch Linux install. For now, I don't have time to dig further into what may be causing the duplicate entries, but I will follow up if I find something more, or if anyone has any suggestions. Thanks!

Error

(Pdb) sorted(available)
*** TypeError: unorderable types: FixtureDef() < FixtureDef()

Duplicate Entries

 (0,
  '_pytest.tmpdir',
  '/path/to/tox/lib/python3.4/site-packages/_pytest/tmpdir.py:110',
  'tmpdir',
  <FixtureDef name='tmpdir' scope='function' baseid='' >),
 (0,
  '_pytest.tmpdir',
  '/path/to/tox/lib/python3.4/site-packages/_pytest/tmpdir.py:110',
  'tmpdir',
  <FixtureDef name='tmpdir' scope='function' baseid='' >),

Tox Environment (bug present)

testapp runtests: commands[0] | pip list
backports.shutil-get-terminal-size (1.0.0)
decorator (4.0.10)
ipdb (0.10.1)
ipython (4.2.0)
ipython-genutils (0.1.0)
pexpect (4.1.0)
pickleshare (0.7.2)
pip (8.1.2)
ptyprocess (0.5.1)
pudb (2016.2)
py (1.4.31)
Pygments (2.1.3)
pytest (2.9.2)
pytest-splinter (1.7.3)
pytest-sugar (0.7.1)
selenium (2.53.5)
setuptools (23.0.0)
simplegeneric (0.8.1)
splinter (0.7.3)
termcolor (1.1.0)
traitlets (4.2.1)
urwid (1.3.1)
wheel (0.29.0)
testapp runtests: commands[1] | python --version
Python 3.4.4
testapp runtests: commands[2] | py.test --version
This is pytest version 2.9.2, imported from /path/to/tox/lib/python3.4/site-packages/pytest.py
setuptools registered plugins:
  pytest-splinter-1.7.3 at /path/to/tox/lib/python3.4/site-packages/pytest_splinter/plugin.py
  pytest-sugar-0.7.1 at /path/to/tox/lib/python3.4/site-packages/pytest_sugar.py

Arch Environment (no tox - no bug)

This is pytest version 2.9.0, imported from /usr/lib/python3.5/site-packages/pytest.py
setuptools registered plugins:
  pytest-cov-2.2.1 at /usr/lib/python3.5/site-packages/pytest_cov/plugin.py
  pytest-splinter-1.7.3 at /usr/lib/python3.5/site-packages/pytest_splinter/plugin.py
  pytest-mock-1.0 at /usr/lib/python3.5/site-packages/pytest_mock.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: fixturesanything involving fixtures directly or indirectlytype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions