Skip to content

provide tools for testing projects that use mypy (e.g. mypy.tests.data pytest plugin) #4366

Closed
@chadrik

Description

@chadrik

I was very glad to see that mypy.tests was added into the mypy package a few releases back, because that opened up the possibility of using mypy.tests.data as a pytest plugin for testing other projects. I used it in the static typing tests for attrs: https://github.com/chadrik/attrs/blob/pyi_stubs/tests/test_stubs.py

Unfortunately commit e03780623 added an import of mypy.test.config which causes an error because the module expect to find a test-data/unit directory at the same level as the root mypy directory:

tests/test_stubs.py:8: in <module>
    from mypy.test.data import parse_test_cases, DataSuite
.tox/stubs/lib/python3.6/site-packages/mypy/test/data.py:14: in <module>
    from mypy.test.config import test_temp_dir
.tox/stubs/lib/python3.6/site-packages/mypy/test/config.py:14: in <module>
    'Test data prefix ({}) not set correctly'.format(test_data_prefix)

I'm pip installing mypy, so naturally it's not there.

I recognize that I've gone a bit out on a limb using mypy.tests.data since it's not a public API, but it's really really useful. I'd like to request that this become a public plugin, and I think a good first step towards this is to make the constants stored in mypy.tests.config configurable via pytest. If you like the idea, I'm glad to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions