-
Notifications
You must be signed in to change notification settings - Fork 339
uvx --python=3.12 unittest2pytest --write . #539
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
base: master
Are you sure you want to change the base?
Conversation
2e9b5ed to
4b7199f
Compare
acdha
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good move — in the past we tried to stick with stdlib only to avoid people struggling around dependency management but the tools have improved a lot and that argument carries a lot less weight now (pysolr turns 20 in 3 years!).
4b7199f to
3004189
Compare
DhavalGojiya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome.
| KazooException = None | ||
|
|
||
| # Add this line to prevent pytest from collecting the imported class | ||
| SolrTestCase.__test__ = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern with this is that it seems like it could set us up for a future change to cause it to ignore SolrTestCase in its original location since we're mutating that as well. I think we could avoid that risk by making the SolrTestCaseMixin do more of the work in SolrTestCase's constructor so we could import only the mixin, but it feels like there should be a better way to avoid this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern with this is that it seems like it could set us up for a future change to cause it to ignore
SolrTestCasein its original location since we're mutating that as well. I think we could avoid that risk by making theSolrTestCaseMixindo more of the work inSolrTestCase's constructor so we could import only the mixin, but it feels like there should be a better way to avoid this.
Interesting, and you are absolutely right.
If we set SolrTestCase.__tests__ = False in the test_cloud.py module level file.
Because the module is cached in sys.modules, the same SolrTestCase class object (including the mutated attribute) will be reused and after this test_cloud.py file execution if any other module try to import SolrTestCase class they need to remove the above __tests__= False side effects from the SolrTestCase class, after inherit this class into any new class.
Reference
%
uvx --python=3.12 unittest2pytest --write .# https://github.com/pytest-dev/unittest2pytestLike #535 but with a different tool.