Skip to content

Commit 9d452c0

Browse files
adapt the way lxml is imported to adapt to it not being any more
1 parent 8756f9f commit 9d452c0

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

mypy/test/testcheck.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
try:
2828
import lxml
2929
except ImportError:
30-
lxml = None
30+
lxml_import_failure = True
3131

3232

3333
import pytest
@@ -55,7 +55,7 @@ class TypeCheckSuite(DataSuite):
5555
files = typecheck_files
5656

5757
def run_case(self, testcase: DataDrivenTestCase) -> None:
58-
if lxml is None and os.path.basename(testcase.file) == "check-reports.test":
58+
if lxml_import_failure and os.path.basename(testcase.file) == "check-reports.test":
5959
pytest.skip("Cannot import lxml. Is it installed?")
6060
incremental = (
6161
"incremental" in testcase.name.lower()

mypy/test/testcmdline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
try:
2323
import lxml
2424
except ImportError:
25-
lxml = None
25+
lxml_import_failure = True
2626

2727
import pytest
2828

@@ -38,7 +38,7 @@ class PythonCmdlineSuite(DataSuite):
3838
native_sep = True
3939

4040
def run_case(self, testcase: DataDrivenTestCase) -> None:
41-
if lxml is None and os.path.basename(testcase.file) == "reports.test":
41+
if lxml_import_failure and os.path.basename(testcase.file) == "reports.test":
4242
pytest.skip("Cannot import lxml. Is it installed?")
4343
for step in [1] + sorted(testcase.output2):
4444
test_python_cmdline(testcase, step)

mypy/test/testreports.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
try:
1111
import lxml
1212
except ImportError:
13-
lxml = None
13+
lxml_import_failure = True
1414

1515
import pytest
1616

1717

1818
class CoberturaReportSuite(Suite):
19-
@pytest.mark.skipif(lxml is None, reason="Cannot import lxml. Is it installed?")
19+
@pytest.mark.skipif(lxml_import_failure, reason="Cannot import lxml. Is it installed?")
2020
def test_get_line_rate(self) -> None:
2121
assert_equal("1.0", get_line_rate(0, 0))
2222
assert_equal("0.3333", get_line_rate(1, 3))
2323

24-
@pytest.mark.skipif(lxml is None, reason="Cannot import lxml. Is it installed?")
24+
@pytest.mark.skipif(lxml_import_failure, reason="Cannot import lxml. Is it installed?")
2525
def test_as_xml(self) -> None:
2626
import lxml.etree as etree
2727

0 commit comments

Comments
 (0)