Skip to content

[self-tests] tests fail against Pytest 7 #214

Open
@stanislavlevin

Description

@stanislavlevin

With Pytest 7 benchmark tests fail:

FAILED tests/test_benchmark.py::test_basic - Failed: nomatch: '*collected 5 i...
FAILED tests/test_benchmark.py::test_skip - Failed: nomatch: '*collected 5 it...
FAILED tests/test_benchmark.py::test_disable - Failed: nomatch: '*collected 5...
FAILED tests/test_benchmark.py::test_only_benchmarks - Failed: nomatch: '*col...
====== 4 failed, 216 passed, 12 skipped, 5 warnings in 389.22s (0:06:29) =======

failure report for one test:

=================================== FAILURES ===================================
__________________________________ test_basic __________________________________
/usr/src/RPM/BUILD/python3-module-pytest-benchmark-3.4.1/tests/test_benchmark.py:1028:
 in test_basic
    result.stdout.fnmatch_lines([
E   Failed: nomatch: '*collected 5 items'
E       and: '============================= test session starts ======================
========'
E       and: 'platform linux -- Python 3.10.2, pytest-7.0.1, pluggy-1.0.0 -- /usr/src/
RPM/BUILD/python3-module-pytest-benchmark-3.4.1/.tox/py310-nocov/bin/python'
E       and: 'cachedir: .pytest_cache'
E       and: 'benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min
_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_
iterations=100000)'
E       and: 'rootdir: /usr/src/tmp/pytest-of-builder/pytest-0/test_basic0'
E       and: 'plugins: benchmark-3.4.1, aspectlib-1.4.2'
E   fnmatch: '*collected 5 items'
E      with: 'collecting ... collected 5 items'
E   nomatch: 'test_basic.py::*test_basic PASSED*'
E       and: ''
E   fnmatch: 'test_basic.py::*test_basic PASSED*'
E      with: 'test_basic.py::test_basic PASSED                                        
 [ 20%]'
E   nomatch: 'test_basic.py::test_slow PASSED*'
E       and: 'test_basic.py::test_fast PASSED                                         
 [ 40%]'
E   fnmatch: 'test_basic.py::test_slow PASSED*'
E      with: 'test_basic.py::test_slow PASSED                                         
 [ 60%]'
E   fnmatch: 'test_basic.py::test_slower PASSED*'
E      with: 'test_basic.py::test_slower PASSED                                       
 [ 80%]'
E   fnmatch: 'test_basic.py::test_xfast PASSED*'
E      with: 'test_basic.py::test_xfast PASSED                                        
 [100%]'
E   nomatch: 'test_basic.py::test_fast PASSED*'
E       and: ''
E       and: ''
E       and: '------------------------------------------------------------------------

...

E   remains unmatched: 'test_basic.py::test_fast PASSED*'

...

----------------------------- Captured stdout call -----------------------------
running: /usr/src/RPM/BUILD/python3-module-pytest-benchmark-3.4.1/.tox/py310-nocov/bin/python -mpytest --basetemp=/usr/src/tmp/pytest-of-builder/pytest-0/test_basic0/runpytest-0 -vv --doctest-modules /usr/src/tmp/pytest-of-builder/pytest-0/test_basic0/test_basic.py
     in: /usr/src/tmp/pytest-of-builder/pytest-0/test_basic0
============================= test session starts ==============================
platform linux -- Python 3.10.2, pytest-7.0.1, pluggy-1.0.0 -- /usr/src/RPM/BUILD/python3-module-pytest-benchmark-3.4.1/.tox/py310-nocov/bin/python
cachedir: .pytest_cache
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /usr/src/tmp/pytest-of-builder/pytest-0/test_basic0
plugins: benchmark-3.4.1, aspectlib-1.4.2
collecting ... collected 5 items

test_basic.py::test_basic PASSED                                         [ 20%]
test_basic.py::test_fast PASSED                                          [ 40%]
test_basic.py::test_slow PASSED                                          [ 60%]
test_basic.py::test_slower PASSED                                        [ 80%]
test_basic.py::test_xfast PASSED                                         [100%]
...

The actual order of reported passed tests differs from the expected one.
This is due to pytest-dev/pytest#5196: Tests are now ordered by definition order in more cases.

I think there is no point to check the behavior of duplicated tests functions and I can only assume that originally this was a typo. In my opinion - there are 2 solutions - removal of the first duplicated test_fast function or renaming it and syncing all affected tests' assumptions.

See also pytest-dev/pytest#9724

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions