python-scripts/daps-xmlwellformed/tests/test_lxml_version.py
raw| 1 | import pytest |
| 2 | |
| 3 | |
| 4 | def test_required_lxml(monkeypatch): |
| 5 | # Given |
| 6 | from lxml import etree |
| 7 | import sys |
| 8 | |
| 9 | module = "dxwf" |
| 10 | if module in sys.modules: |
| 11 | # Force deleting them if it is already loaded from |
| 12 | # other tests |
| 13 | del sys.modules[module] |
| 14 | |
| 15 | with monkeypatch.context() as m: |
| 16 | # simulate a very low version of lxml |
| 17 | m.setattr(etree, "LXML_VERSION", (1, 42, 42, 0)) |
| 18 | with pytest.raises(SystemExit): |
| 19 | import dxwf |