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

Treat methodName="runTest" similar to unittest.TestCase #373

Merged
merged 2 commits into from
May 13, 2024

Conversation

ncopa
Copy link
Contributor

@ncopa ncopa commented May 13, 2024

pytest 82. relies on a feature of unittest.TestCase where the initialization of it with the default methodName="runTest" is treated specially, allowing it to insantiate even without runTest method actually existing.

See under "Changed in Python 3.2" in unittest.TestCase docs

This fixes the error with pytest 8.2:
AttributeError: 'TestUtil' object has no attribute 'runTest'. Did you mean: 'subTest'?

Fixes: #372
ref: https://docs.python.org/3/library/unittest.html#unittest.TestCase
ref: https://github.com/python/cpython/blob/51aefc5bf907ddffaaf083ded0de773adcdf08c8/Lib/unittest/case.py#L419-L426
ref: pytest-dev/pytest#12263 (comment)

@ncopa ncopa force-pushed the fix-pytest-8.2 branch 2 times, most recently from fb822a8 to e4f0b99 Compare May 13, 2024 12:21
@jelmer jelmer enabled auto-merge May 13, 2024 12:29
Copy link
Member

@jelmer jelmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run ruff format, otherwise LGTM

pytest 8.2 relies on a feature of `unittest.TestCase` where the
initialization of it with the default `methodName="runTest"` is treated
specially, allowing it to insantiate even without `runTest` method
actually existing.

See under "Changed in Python 3.2" in unittest.TestCase docs

This fixes the error with pytest 8.2:
  AttributeError: 'TestUtil' object has no attribute 'runTest'. Did you mean: 'subTest'?

Fixes: testing-cabal#372
ref: https://docs.python.org/3/library/unittest.html#unittest.TestCase
ref: https://github.com/python/cpython/blob/51aefc5bf907ddffaaf083ded0de773adcdf08c8/Lib/unittest/case.py#L419-L426
ref: pytest-dev/pytest#12263 (comment)
auto-merge was automatically disabled May 13, 2024 13:26

Head branch was pushed to by a user without write access

@ncopa
Copy link
Contributor Author

ncopa commented May 13, 2024

ruff formatted it (I hope). sorry for that.

@ncopa ncopa requested a review from jelmer May 13, 2024 13:33
@jelmer jelmer enabled auto-merge May 13, 2024 13:41
@jelmer jelmer merged commit 48e689b into testing-cabal:master May 13, 2024
8 checks passed
@ncopa ncopa deleted the fix-pytest-8.2 branch May 13, 2024 15:07
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 this pull request may close these issues.

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