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

Meta issue: improving test runner #11662

Closed
3 tasks done
sobolevn opened this issue Dec 4, 2021 · 4 comments · Fixed by #12813
Closed
3 tasks done

Meta issue: improving test runner #11662

sobolevn opened this issue Dec 4, 2021 · 4 comments · Fixed by #12813
Labels
feature meta Issues tracking a broad area of work topic-developer Issues relevant to mypy developers topic-tests

Comments

@sobolevn
Copy link
Member

sobolevn commented Dec 4, 2021

Right now there are several things I would love to see improved in our unit tests:

I will send a couple of PRs with these features if no one has any rejections 🙂

@sobolevn sobolevn changed the title Meta issue: improoving test runner Meta issue: improving test runner Dec 4, 2021
@sobolevn
Copy link
Member Author

sobolevn commented Dec 5, 2021

My progress:

(.venv) ~/Desktop/mypy  master ✗                                                  5 ⚠️
» pytest mypy/test/testcheck.py --collect-only================================ test session starts =================================
platform darwin -- Python 3.10.0, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /Users/sobolev/Desktop/mypy, configfile: pytest.ini
plugins: cov-2.12.1, xdist-1.34.0, forked-1.3.0
collected 68 items                                                                   

<Package test>
  <Module testcheck.py>
    <DataSuiteCollector TypeCheckSuite>
      <DataFileCollector check-basic.test>
        <DataDrivenTestCase testEmptyFile>
        <DataDrivenTestCase testAssignmentAndVarDef>
        <DataDrivenTestCase testConstructionAndAssignment>
        <DataDrivenTestCase testInheritInitFromObject>
        <DataDrivenTestCase testImplicitInheritInitFromObject>
        <DataDrivenTestCase testTooManyConstructorArgs>
        <DataDrivenTestCase testVarDefWithInit>
        <DataDrivenTestCase testInheritanceBasedSubtyping>
        <DataDrivenTestCase testDeclaredVariableInParentheses>
        <DataDrivenTestCase testIncompatibleAssignmentAmbiguousShortnames>
        <DataDrivenTestCase testFunction>
        <DataDrivenTestCase testNotCallable>
        <DataDrivenTestCase testSubtypeArgument>
        <DataDrivenTestCase testInvalidArgumentCount>
        <DataDrivenTestCase testMissingPositionalArguments>
        <DataDrivenTestCase testLocalVariables>
        <DataDrivenTestCase testLocalVariableScope>
        <DataDrivenTestCase testFunctionArguments>
        <DataDrivenTestCase testLocalVariableInitialization>
        <DataDrivenTestCase testVariableInitializationWithSubtype>
        <DataDrivenTestCase testInvalidReturn>
        <DataDrivenTestCase testTopLevelContextAndInvalidReturn>
        <DataDrivenTestCase testEmptyReturnInAnyTypedFunction>
        <DataDrivenTestCase testEmptyYieldInAnyTypedFunction>
        <DataDrivenTestCase testModule__name__>
        <DataDrivenTestCase testModule__doc__>
        <DataDrivenTestCase testModule__file__>
        <DataDrivenTestCase test__package__>
        <DataDrivenTestCase testLocalVariableShadowing>
        <DataDrivenTestCase testGlobalDefinedInBlockWithType>
        <DataDrivenTestCase testFunctionSignatureAsComment>
        <DataDrivenTestCase testMethodSignatureAsComment>
        <DataDrivenTestCase testTrailingCommaParsing>
        <DataDrivenTestCase testInitReturnTypeError>
        <DataDrivenTestCase testWritesCache>
        <DataDrivenTestCase testWritesCacheErrors>
        <DataDrivenTestCase testModuleAsTypeNoCrash>
        <DataDrivenTestCase testModuleAsTypeNoCrash2>
        <DataDrivenTestCase testPartialTypeComments>
        <DataDrivenTestCase testNoneHasBool>
        <DataDrivenTestCase testNoneHasBoolShowNoneErrorsFalse>
        <DataDrivenTestCase testAssignmentInvariantNoteForList>
        <DataDrivenTestCase testAssignmentInvariantNoteForDict>
        <DataDrivenTestCase testDistinctTypes>
        <DataDrivenTestCase testReturnAnyFromFunctionDeclaredToReturnObject>
        <DataDrivenTestCase testImportModuleAsClassMember>
        <DataDrivenTestCase testLocalImportModuleAsClassMember>
      <DataFileCollector check-union-or-syntax.test>
        <DataDrivenTestCase testUnionOrSyntaxWithTwoBuiltinsTypes>
        <DataDrivenTestCase testUnionOrSyntaxWithThreeBuiltinsTypes>
        <DataDrivenTestCase testUnionOrSyntaxWithTwoTypes>
        <DataDrivenTestCase testUnionOrSyntaxWithThreeTypes>
        <DataDrivenTestCase testUnionOrSyntaxWithLiteral>
        <DataDrivenTestCase testUnionOrSyntaxWithBadOperator>
        <DataDrivenTestCase testUnionOrSyntaxWithBadOperands>
        <DataDrivenTestCase testUnionOrSyntaxWithGenerics>
        <DataDrivenTestCase testUnionOrSyntaxWithQuotedFunctionTypes>
        <DataDrivenTestCase testUnionOrSyntaxWithQuotedVariableTypes>
        <DataDrivenTestCase testUnionOrSyntaxWithTypeAliasWorking>
        <DataDrivenTestCase testUnionOrSyntaxWithinRuntimeContextNotAllowed>
        <DataDrivenTestCase testUnionOrSyntaxWithinRuntimeContextNotAllowed2>
        <DataDrivenTestCase testUnionOrSyntaxInComment>
        <DataDrivenTestCase testUnionOrSyntaxFutureImport>
        <DataDrivenTestCase testUnionOrSyntaxMissingFutureImport>
        <DataDrivenTestCase testUnionOrSyntaxInStubFile>
        <DataDrivenTestCase testUnionOrSyntaxInMiscRuntimeContexts>
        <DataDrivenTestCase testUnionOrSyntaxRuntimeContextInStubFile>
        <DataDrivenTestCase testUnionOrSyntaxInIsinstance>
        <DataDrivenTestCase testUnionOrSyntaxInIsinstanceNotSupported>

============================ 68 tests collected in 0.24s =============================

Now works.

But, for some reason - this does not:

(.venv) ~/Desktop/mypy  master ✗                                                     
» pytest mypy/test/testcheck.py::check-basic.test --collect-only
================================ test session starts =================================
platform darwin -- Python 3.10.0, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /Users/sobolev/Desktop/mypy, configfile: pytest.ini
plugins: cov-2.12.1, xdist-1.34.0, forked-1.3.0
collected 0 items                                                                    

============================ no tests collected in 0.14s =============================
ERROR: not found: /Users/sobolev/Desktop/mypy/mypy/test/testcheck.py::check-basic.test
(no name '/Users/sobolev/Desktop/mypy/mypy/test/testcheck.py::check-basic.test' in any of [<Module testcheck.py>])

🤔

@bluetech
Copy link
Contributor

bluetech commented Dec 6, 2021

But, for some reason - this does not:

It needs to be

pytest mypy/test/testcheck.py::TypeCheckSuite::check-basic.test --collect-only

If you add -q to the --collect-only it gives a flat format which makes the nodeids more clear. I think it makes sense that the class is in the nodeid, but it should be possible to get rid of it if you want.

JukkaL pushed a commit that referenced this issue Dec 15, 2021
I found lots of duplicate test names. It might hide important errors, be hard to reproduce 
or rerun.

Refs #11662

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
@hauntsaninja
Copy link
Collaborator

One other wish list item for me is to make it easy to exclude tests that depend on lxml. This would be useful for 3.11-dev / for future prerelease Pythons. It would also be useful for wheel builds, we currently do pytest -k 'not (reports.test or testreports)' when testing wheels to work around issues with lxml installation.

tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this issue Jan 20, 2022
I found lots of duplicate test names. It might hide important errors, be hard to reproduce 
or rerun.

Refs python#11662

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
@97littleleaf11 97littleleaf11 added the meta Issues tracking a broad area of work label Feb 20, 2022
@JelleZijlstra JelleZijlstra added topic-developer Issues relevant to mypy developers topic-tests labels Mar 19, 2022
@ethanhs
Copy link
Collaborator

ethanhs commented May 19, 2022

I believe all of the original work here that @sobolevn wanted to accomplish is done. For the lxml tests I opened #12813

So once that is merged I think we can close this.

JukkaL pushed a commit that referenced this issue May 19, 2022
Detect if lxml is importable in the test suite, if it is not, then skip the report tests which 
depend on it.

This is useful for enabling CI on new Python versions that may not have lxml wheels yet.

Closes #11662.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature meta Issues tracking a broad area of work topic-developer Issues relevant to mypy developers topic-tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants