-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Now you can run separate mypy test modules 🎉 #11668
Conversation
Live example of a failing test: https://github.com/python/mypy/runs/4424328047?check_suite_focus=true#step:8:179 |
Test numbers:
I hope that the time difference is caused by GitHub Action runner fluctuations and not my changes 🙂 Update: previous failing commit took I am also going to friendly ping @bluetech as pytest's core dev and mypy contributor. Maybe you would have some time to give this PR a quick review? 🙂 |
Nice! Whenever I worked on mypy I did the "comment out the other files" bit which is annoying. My only suggestion is to not make diff --git a/mypy/test/data.py b/mypy/test/data.py
index 559b5be2a..65fb26735 100644
--- a/mypy/test/data.py
+++ b/mypy/test/data.py
@@ -247,7 +247,7 @@ class DataDrivenTestCase(pytest.Item):
# TODO: add a better error message for when someone uses skip and xfail at the same time
elif self.xfail:
self.add_marker(pytest.mark.xfail)
- suite = self.parent.obj()
+ suite = self.getparent(DataSuiteCollector).obj()
suite.setup()
try:
suite.run_case(self)
@@ -609,11 +609,12 @@ class DataSuiteCollector(pytest.Class):
yield DataFileCollector.from_parent(parent=self, name=data_file)
-class DataFileCollector(pytest.Class):
+class DataFileCollector(pytest.Collector):
"""Represents a single `.test` data driven test file.
More context: https://github.com/python/mypy/issues/11662
"""
+ parent: DataSuiteCollector
@classmethod # We have to fight with pytest here:
def from_parent( # type: ignore[override]
@@ -623,14 +624,13 @@ class DataFileCollector(pytest.Class):
name: str,
) -> 'DataFileCollector':
instance = super().from_parent(parent, name=name) # type: ignore[no-untyped-call]
- instance.obj = parent.obj # We need to copy `DataSuite` object deeper.
return instance
def collect(self) -> Iterator['DataDrivenTestCase']:
yield from split_test_cases(
parent=self,
- suite=self.obj,
- file=os.path.join(self.obj.data_prefix, self.name),
+ suite=self.parent.obj,
+ file=os.path.join(self.parent.obj.data_prefix, self.name),
)
|
Thank you! Fixed! |
This is great, thank you all! :-) |
One test is failing right now on purpose, so you can take a look on how new namespaces work.
I will fix it in the next commit, I hope the logs will be preserved for some time to see them.
Here's a quick recap of everything in this PR:
.test
file withmypy/test/testcheck.py::TypeCheckSuite::check-basic.test
mypy/test/testcheck.py::TypeCheckSuite::check-basic.test::testAssignmentAndVarDef
Screenshots:
Refs #11662