From 22d4f1d2356f3858e2de8244531937ab85cac44a Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Wed, 29 Dec 2021 18:04:10 -0600 Subject: [PATCH] Skip lxml and mypyc external tests against built wheels (#11872) Co-authored-by: hauntsaninja <> --- misc/build_wheel.py | 15 ++++++++++++--- mypy/test/testreports.py | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/misc/build_wheel.py b/misc/build_wheel.py index 4c923279742e..4738115aae26 100644 --- a/misc/build_wheel.py +++ b/misc/build_wheel.py @@ -73,19 +73,28 @@ def create_environ(python_version: str) -> Dict[str, str]: 'MYPY_USE_MYPYC=1 MYPYC_OPT_LEVEL=2 PIP_NO_BUILD_ISOLATION=no' ) + # lxml doesn't have a wheel for Python 3.10 on the manylinux image we use. + # lxml has historically been slow to support new Pythons as well. env['CIBW_BEFORE_TEST'] = ( - 'pip install -r {project}/mypy/test-requirements.txt' + 'pip install -r <(grep -v lxml {project}/mypy/test-requirements.txt)' ) # pytest looks for configuration files in the parent directories of where the tests live. # since we are trying to run the tests from their installed location, we copy those into # the venv. Ew ew ew. + # We don't run tests that need lxml since we don't install lxml + # We don't run external mypyc tests since there's some issue with compilation on the + # manylinux image we use. env['CIBW_TEST_COMMAND'] = """ ( DIR=$(python -c 'import mypy, os; dn = os.path.dirname; print(dn(dn(mypy.__path__[0])))') - && TEST_DIRS=$(python -c 'import mypy.test; import mypyc.test; print(mypy.test.__path__[0], mypyc.test.__path__[0])') && cp '{project}/mypy/pytest.ini' '{project}/mypy/conftest.py' $DIR - && MYPY_TEST_PREFIX='{project}/mypy' pytest $TEST_DIRS + + && MYPY_TEST_DIR=$(python -c 'import mypy.test; print(mypy.test.__path__[0])') + && MYPY_TEST_PREFIX='{project}/mypy' pytest $MYPY_TEST_DIR -k 'not (reports.test or testreports)' + + && MYPYC_TEST_DIR=$(python -c 'import mypyc.test; print(mypyc.test.__path__[0])') + && pytest $MYPYC_TEST_DIR -k 'not test_external' ) """.replace('\n', ' ') diff --git a/mypy/test/testreports.py b/mypy/test/testreports.py index 84ac3e005bec..75f24d514431 100644 --- a/mypy/test/testreports.py +++ b/mypy/test/testreports.py @@ -4,8 +4,6 @@ from mypy.test.helpers import Suite, assert_equal from mypy.report import CoberturaPackage, get_line_rate -import lxml.etree as etree # type: ignore - class CoberturaReportSuite(Suite): def test_get_line_rate(self) -> None: @@ -13,6 +11,8 @@ def test_get_line_rate(self) -> None: assert_equal('0.3333', get_line_rate(1, 3)) def test_as_xml(self) -> None: + import lxml.etree as etree # type: ignore + cobertura_package = CoberturaPackage('foobar') cobertura_package.covered_lines = 21 cobertura_package.total_lines = 42