-
-
Notifications
You must be signed in to change notification settings - Fork 378
move **/tests/ to **/_tests/ #2628
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
Conversation
|
ah, |
|
I poked at this a bit and adding Like the comment in the file says, we can essentially put |
huh, I don't get that far: File "/home/h/Git/trio/trio/_tests/conftest.py", line 10, in <module>
from ..testing import trio_test, MockClock
File "/home/h/Git/trio/trio/testing/__init__.py", line 7, in <module>
from ._sequencer import Sequencer
File "/home/h/Git/trio/trio/testing/_sequencer.py", line 11, in <module>
from .. import Event
ImportError: Error importing plugin "trio._tests.conftest": cannot import name 'Event' from 'trio' (unknown location)though maybe I've messed up my environment somehow. Feel free to push a commit that makes it a plugin if you can get it to work. |
|
I should probably mention this now before I forget: we should have a dummy |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2628 +/- ##
==========================================
- Coverage 92.46% 91.73% -0.73%
==========================================
Files 118 118
Lines 16431 16444 +13
Branches 2970 2970
==========================================
- Hits 15193 15085 -108
- Misses 1124 1244 +120
- Partials 114 115 +1
|
|
I'm still having some env issues with running the tests myself sometimes, but they seem to pass CI - so it should be fine on a clean install. Added |
A5rocks
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.
Presumably doing import trio.tests will work as a test but I don't think we need one.
1725f04 to
92ae278
Compare
|
Cleaned up and added an import+deprecation test. Formatting seems to have hit a snag with ... something unrelated to this PR. |
|
@A5rocks this one is also ready for review |
A5rocks
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.
Cursory review comments, I might find something else in a second review!
trio/tests.py
Outdated
| def __getattr__(self, attr: str) -> Any: | ||
| warn_deprecated( | ||
| f"trio.tests.{attr}", | ||
| "0.23.0", |
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'm decently sure this deprecation should be kicked off until 0.24.0 -- this will probably get out in a 0.22.0 that removes support for Python 3.7 which will be a major (-> minor cause 0.) bump.
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.
Sounds good, I just copy-pasted another deprecation warning without considering the versioning :)
|
FYI master fixes the CI runs, so just merge that in! |
c12ce07 to
6be34f3
Compare
|
rebased on top of master, and fixed review comments |
Ah. Codecov doesn't see them anymore because So we should maybe switch to starting coverage before pytest? https://stackoverflow.com/a/62224494 |
|
Sounds good, we want to redo codecov a bit too since it doesn't work with like Windows and whatever ATM. So feel free to change things slightly if necessary! |
ce7fddc to
00fe706
Compare
|
uh, looks like codecov isn't turning up as a check at all now. I'll just revert it and we can put a pin into running with |
A5rocks
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.
Looks mostly good, I'd like @njsmith to weigh in cause I'm not too used to changes like this!
trio/tests.py
Outdated
| # don't ask which of the _tests imports is necessary | ||
| import trio._tests | ||
|
|
||
| from . import _tests |
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'm a bit confused by this, won't the namespaces shadow and so the first is useless?
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.
Don't you see the comment?? 😂
I don't remember what caused the confusion back when I was messing around with it. Neither is technically useless atm, as they import the same package as different names. Removing the latter makes no difference to functionality, and removing the first one requires exchanging references to trio._tests to be _tests. But importing from the local package seems superior, so I'll do the latter.
|
Fixed review comments, removing unnecessary imports. And reading the PR after having forgotten what the code does unsurprisingly lead to some improved comments and tests 😇 |
|
|
||
|
|
||
| # https://stackoverflow.com/questions/2447353/getattr-on-a-module | ||
| sys.modules[__name__] = TestsDeprecationWrapper() # type: ignore[assignment] |
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'm not sure we really need to be this careful about backcompat here -- surely people aren't actually using trio.tests, right? -- but I guess it's harmless.
Though... I guess we actually want to get rid of trio.tests entirely, so maybe we should issue the warning on import? If someone is importing it but not using it (for some reason), then they won't get a warning, but they'll still get broken in the future when we delete this file.
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.
ah, took me a minute but figured out how to get it to warn on import as well. Only thing it doesn't warn on now that would break is import trio; assert trio.tests - i.e. access of the module, but without importing it, and not accessing any of it's attributes. (I tried changing from using __getattr__ to __getattribute__ but that made no difference in this case). There's probably some way of addressing that, but now we're getting into very weird cases.
a74edda to
915c22c
Compare
|
removed the test import from |
|
@A5rocks any reservations about merging this? |
Simply renames the directories trio/tests and trio/_core/tests, and updates references to them.
Addresses some (or all?) problems in #274
Fixes the second task in #2625
@njsmith - especially wrt to considerations for #274