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 25, 2023
1 parent 55dbde2 commit c744588
Show file tree
Hide file tree
Showing 5 changed files with 26 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
10 changes: 10 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

defusedxml 0.8.0
----------------

*Release date: 2023*

- Fix testing without lxml
- Test on 3.13-dev and PyPy 3.9


defusedxml 0.8.0rc2
-------------------

Expand All @@ -9,6 +18,7 @@ defusedxml 0.8.0rc2
- Silence deprecation warning in `defuse_stdlib`.
- Update lxml safety information


defusedxml 0.8.0rc1
-------------------

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,13 @@ during working hours as part of semantics's open source initiative.
Injection](https://www.owasp.org/index.php/Testing_for_XML_Injection_(OWASP-DV-008))
# Changelog

## defusedxml 0.8.0

*Release date: 2023*

- Fix testing without lxml
- Test on 3.13-dev and PyPy 3.9

## defusedxml 0.8.0rc2

*Release date: 29-Sep-2023*
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 c744588

Please sign in to comment.