testing-cabal / testtools

Testtools - tasteful testing for python
https://testtools.readthedocs.io/en/latest/
Other
94 stars 88 forks source link

Pytest 8: AttributeError: 'TestExpectedException' object has no attribute 'runTest'. Did you mean: 'subTest'? #372

Closed hrnciar closed 5 months ago

hrnciar commented 5 months ago

Hello,

we are using pytest for running bandit and python-etcd3gw tests. Since pytest 8 the tests are failing with AttributeError: 'XXX' object has no attribute 'runTest'. Did you mean: 'subTest'? See:

Reproducer:

$ git clone git@github.com:testing-cabal/testtools.git
$ cd testtools
[testtools (master)]$ tox -e py312
...

[testtools (master)]$ .tox/py312/bin/pip install 'pytest>=8'
[testtools (master)]$ .tox/py312/bin/pytest testtools/tests
...
AttributeError: 'TestExpectedException' object has no attribute 'runTest'. Did you mean: 'subTest'?
11 warnings, 218 errors

[testtools (master)]$ .tox/py312/bin/pip install 'pytest<8'
[testtools (master)]$ .tox/py312/bin/pytest testtools/tests
...
38 failed, 1328 passed, 7 skipped, 2 xfailed, 59 warnings
jelmer commented 5 months ago

Please use either the test tools test runner or the native python test runner (unittest)

We're open to PRs that improve support for running the test with third party runners like pytest, but it's not a priority for the project.

jelmer commented 5 months ago

See also #332

ncopa commented 5 months ago

Details why this happens is found here https://github.com/pytest-dev/pytest/issues/12263#issuecomment-2081434468