Skip to content

Commit

Permalink
Fixed test failures on Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
spookylukey committed Sep 30, 2024
1 parent 1d90359 commit a4ba4fe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Intended Audience :: Developers
Operating System :: OS Independent
License :: OSI Approved :: MIT License
Expand Down
21 changes: 17 additions & 4 deletions tests/test_xml.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import sys
from pathlib import Path

Expand Down Expand Up @@ -104,9 +105,7 @@ def _file_to_xml(path: Path):
@pytest.mark.skipif(sys.version_info < (3, 9), reason="AST different on Python 3.8")
def test_xml_everything():
# Smoke test to check we didn't break anything.
assert (
_file_to_xml(DIR / "everything.py")
== """
EXPECTED = """
<Module>
<body>
<FunctionDef lineno="2" col_offset="0" type="str" name="function">
Expand Down Expand Up @@ -177,6 +176,7 @@ def test_xml_everything():
</Assign>
</body>
<decorator_list/>
<type_params/>
</FunctionDef>
<FunctionDef lineno="10" col_offset="0" type="str" name="function_kwarg">
<args>
Expand All @@ -196,6 +196,7 @@ def test_xml_everything():
<Pass lineno="11" col_offset="4"/>
</body>
<decorator_list/>
<type_params/>
</FunctionDef>
<FunctionDef lineno="14" col_offset="0" type="str" name="function_star_args">
<args>
Expand All @@ -214,6 +215,7 @@ def test_xml_everything():
<Pass lineno="15" col_offset="4"/>
</body>
<decorator_list/>
<type_params/>
</FunctionDef>
<FunctionDef lineno="18" col_offset="0" type="str" name="function_star_kwargs">
<args>
Expand All @@ -232,6 +234,7 @@ def test_xml_everything():
<Pass lineno="19" col_offset="4"/>
</body>
<decorator_list/>
<type_params/>
</FunctionDef>
<FunctionDef lineno="22" col_offset="0" type="str" name="function_pos_kw_only">
<args>
Expand All @@ -253,6 +256,7 @@ def test_xml_everything():
<Pass lineno="23" col_offset="4"/>
</body>
<decorator_list/>
<type_params/>
</FunctionDef>
<FunctionDef lineno="26" col_offset="0" type="str" name="function_all">
<args>
Expand Down Expand Up @@ -282,6 +286,7 @@ def test_xml_everything():
<Pass lineno="27" col_offset="4"/>
</body>
<decorator_list/>
<type_params/>
</FunctionDef>
<ClassDef lineno="30" col_offset="0" type="str" name="MyClass">
<bases/>
Expand All @@ -290,6 +295,7 @@ def test_xml_everything():
<Pass lineno="31" col_offset="4"/>
</body>
<decorator_list/>
<type_params/>
</ClassDef>
<FunctionDef lineno="34" col_offset="0" type="str" name="function_ann">
<args>
Expand Down Expand Up @@ -388,6 +394,7 @@ def test_xml_everything():
</ctx>
</Name>
</returns>
<type_params/>
</FunctionDef>
<Assign lineno="39" col_offset="0">
<targets>
Expand Down Expand Up @@ -417,4 +424,10 @@ def test_xml_everything():
<type_ignores/>
</Module>
""".lstrip()
)

# Hacks for different Python versios, we may need to just have a dictionary
# of different outputs
if sys.version_info < (3, 12):
EXPECTED = re.subn(r" *<type_params/>\n", "", EXPECTED)[0]

assert _file_to_xml(DIR / "everything.py") == EXPECTED
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
# Remember to add to .github/workflows/build.yml if this is added to.
envlist = py38, py39, py310, py311, mypy
# Remember to add to .github/workflows/tests.yml if this is added to.
envlist = py38, py39, py310, py311, py312, mypy

[testenv]

Expand Down

0 comments on commit a4ba4fe

Please sign in to comment.