-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Improved flags fixturing for for repository unit tests #10190
Improved flags fixturing for for repository unit tests #10190
Conversation
…nit tests In the previous commit we added a pytest fixture which sets and tears down the global flags arg via `set_from_args` for every pytest based unit test. Previously we had added a `set_from_args` in tests or test files to reset the global flags from if they were modified by a previous test. This is no longer necessary because of the work done in the previous commit. Note: We did not modify any tests that use the `unittest.TestCase` class because they don't use pytest fixtures. Thus those tests need to continue operating as they currently do until we shift them to pytest unit tests.
…t_contracts_graph_parsed.py`
We did this so in the next commit we can drop the unnecessary `set_from_args` in the next commit. That will be it's own commit because converting these tests is a restructuring that doing separately makes things easier to follow. That is to say, all changes in this commit were just to convert the tests to pytest, no other changes were made.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10190 +/- ##
==========================================
- Coverage 88.65% 88.63% -0.03%
==========================================
Files 180 180
Lines 22422 22434 +12
==========================================
+ Hits 19879 19885 +6
- Misses 2543 2549 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
In python 3.9 `Generator` was moved to `collections.abc` and deprecated in `typing`. We still support 3.8 and thus need to be conditionally importing `Generator`. We should remove this in the future when we drop support for 3.8.
At the time of this comment it appears that |
resolves #8627
Problem
Our flags are a global. Although hopefully they won't be soon 🤞 Regardless because of their global nature, setting the global flags in one unit test, affected other unit tests. This meant either any unit test had to clean up the global flags at the end OR every test had to reset the global flags at start. The latter was more common because it's easier to code defensively than hope any upstream test appropriately cleans up after itself.
Additionally we didn't have a "standard" way of setting up flags for tests.
Solution
Checklist