Skip to content

Commit

Permalink
test: Test with 3.13, PyPy 3.9, and no lxml
Browse files Browse the repository at this point in the history
- Add tox configuration for Python 3.13 and PyPy 3.9
- Add tox env for testing with and without lxml installed
- Fixed tests when lxml is missing

Signed-off-by: Christian Heimes <[email protected]>
  • Loading branch information
tiran committed Oct 24, 2023
1 parent 55dbde2 commit 13ab612
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
- "3.13-dev"
- "pypy3.9"
image:
- "ubuntu-22.04"
include:
Expand Down
6 changes: 3 additions & 3 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,22 +351,22 @@ def test_exceptions(self):
class TestDefusedLxml(BaseTests):
module = lxml

cyclic_error = lxml_etree.XMLSyntaxError
cyclic_error = getattr(lxml_etree, "XMLSyntaxError", None)

content_binary = True

def parse(self, xmlfile, **kwargs):
try:
tree = self.module.parse(xmlfile, **kwargs)
except lxml_etree.XMLSyntaxError:
self.skipTest("lxml detects entityt reference loop")
self.skipTest("lxml detects entity reference loop")
return self.module.tostring(tree)

def parseString(self, xmlstring, **kwargs):
try:
tree = self.module.fromstring(xmlstring, **kwargs)
except lxml_etree.XMLSyntaxError:
self.skipTest("lxml detects entityt reference loop")
self.skipTest("lxml detects entity reference loop")
return self.module.tostring(tree)

if not LXML3:
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[tox]
envlist = py36,py37,py38,py39,py310,py311,py312,black,pep8py3,doc
envlist = {py36,py37,py38,py39,py310,py311,py312}-{lxml,nolxml},py313,pypy39,black,pep8py3,doc
skip_missing_interpreters = true

[testenv]
commands =
{envpython} {toxinidir}/tests.py
deps =
lxml
lxml: lxml

[testenv:black]
commands = black --check --verbose \
Expand Down Expand Up @@ -48,3 +48,5 @@ python =
3.10: py310
3.11: py311
3.12: py312
3.13: py313
pypy-3.9: pypy39

0 comments on commit 13ab612

Please sign in to comment.