Skip to content

Commit

Permalink
Skip lxml and mypyc external tests against built wheels (#11872)
Browse files Browse the repository at this point in the history
Co-authored-by: hauntsaninja <>
  • Loading branch information
hauntsaninja committed Dec 30, 2021
1 parent fe3b625 commit 22d4f1d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions misc/build_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', ' ')

Expand Down
4 changes: 2 additions & 2 deletions mypy/test/testreports.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
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:
assert_equal('1.0', get_line_rate(0, 0))
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
Expand Down

0 comments on commit 22d4f1d

Please sign in to comment.