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

pytest 8.2.0 regresses collection and now collects non-Test* classes #12425

Closed
3 of 4 tasks
s-t-e-v-e-n-k opened this issue Jun 6, 2024 · 4 comments
Closed
3 of 4 tasks
Labels
stale status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity

Comments

@s-t-e-v-e-n-k
Copy link

s-t-e-v-e-n-k commented Jun 6, 2024

Discovered while testing libcloud with pytest 8.2.0, as seen in https://github.com/apache/libcloud/blob/trunk/libcloud/test/__init__.py#L90 the MockHttp class is also collected and attempted to be instantiated, leading to collection errors like the following:

[   20s] ___________ ERROR collecting libcloud/test/common/test_cloudstack.py ___________
[   20s] libcloud/test/__init__.py:111: in __init__
[   20s]     super().__init__(*args, **kwargs)
[   20s] E   TypeError: LibcloudConnection.__init__() missing 1 required positional argument: 'port'
[   20s] _______ ERROR collecting libcloud/test/common/test_openstack_identity.py _______
[   20s] libcloud/test/__init__.py:111: in __init__
[   20s]     super().__init__(*args, **kwargs)
[   20s] E   TypeError: LibcloudConnection.__init__() missing 1 required positional argument: 'port'
[   20s] _______ ERROR collecting libcloud/test/common/test_openstack_identity.py _______
[   20s] libcloud/test/compute/test_openstack.py:3841: in __init__
[   20s]     super().__init__(*args, **kwargs)
[   20s] libcloud/test/__init__.py:111: in __init__
[   20s]     super().__init__(*args, **kwargs)
[   20s] E   TypeError: LibcloudConnection.__init__() missing 1 required positional argument: 'port'

I bisected this down to first occurring with 1a5e0eb (sixth commit or so of 8.2.0)

pip list output:

Package            Version
------------------ ----------
apipkg             3.0.2
attrs              23.2.0
bcrypt             4.1.3
certifi            2023.11.17
cffi               1.16.0
charset-normalizer 3.3.2
cryptography       42.0.7
fasteners          0.19
idna               3.7
iniconfig          2.0.0
libvirt-python     10.3.0
more-itertools     10.2.0
packaging          24.0
paramiko           3.4.0
pip                24.0
pluggy             1.5.0
py                 1.11.0
pycparser          2.22
PyNaCl             1.5.0
pyOpenSSL          24.1.0
pytest             8.2.0
requests           2.32.2
requests-mock      1.12.1
ruff               0.4.4
setuptools         70.0.0
six                1.16.0
urllib3            2.1.0
wheel              0.43.0
  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible
@RonnyPfannschmidt
Copy link
Member

https://github.com/apache/libcloud/blob/6f1f83d57fb6bbf7d932ea2c4e312ba5fd86fb81/libcloud/test/common/test_cloudstack.py#L119 is fundamentally broken, it was pure dumb luck it ever worked

imho its a upstream bug that was accidentially hidden, not something to support

based on the inheritance tree, yout bugfix hides large parts of the testsuite

@bluetech
Copy link
Member

bluetech commented Jun 6, 2024

As @RonnyPfannschmidt said, my recommendation is to make it such that the __init__ of TestCase sub-classes doesn't do anything, instead do the work in setUp/setUpClass and friends. In your case, try to avoid making test classes subclass from MockHttp class, since it seems it does some stuff on __init__. Instead, use composition -- instantiate self.mock_http = MockHttp(...) in setUp, and tear it down (if necessary) in tearDown.

@bluetech bluetech added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label Jun 6, 2024
Copy link
Contributor

This issue is stale because it has the status: needs information label and requested follow-up information was not provided for 14 days.

@github-actions github-actions bot added the stale label Jun 21, 2024
@s-t-e-v-e-n-k
Copy link
Author

Upstream bug, so closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity
Projects
None yet
Development

No branches or pull requests

3 participants