Skip to content

Commit

Permalink
Add support for Python 3.10 in tests and CI (#550)
Browse files Browse the repository at this point in the history
It also fixes some line numbers in formatted exceptions that changed in
Python 3.10 due to https://bugs.python.org/issue42246 and
https://bugs.python.org/issue43933.
  • Loading branch information
Delgan committed Jan 20, 2022
1 parent 378a400 commit f2d5133
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ jobs:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- 'pypy-3.8'
include:
- os: windows-latest
python-version: '3.9'
python-version: '3.10'
- os: macos-latest
python-version: '3.9'
python-version: '3.10'
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: Implementation :: CPython",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__main__ handler_formatting_with_context_manager.py a 17
__main__ handler_formatting_with_context_manager.py a 16
Traceback (most recent call last):
File "tests/exceptions/source/others/handler_formatting_with_context_manager.py", line 17, in a
1 / 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__main__ message_formatting_with_context_manager.py a 13
__main__ message_formatting_with_context_manager.py a 10
Traceback (most recent call last):
File "tests/exceptions/source/others/message_formatting_with_context_manager.py", line 13, in a
1 / 0
Expand Down
10 changes: 10 additions & 0 deletions tests/test_exceptions_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ def fix_filepath(match):
elif "IndentationError" in exception:
exception = re.sub(r"\n *\^ *\n", "\n", exception)

if sys.version_info < (3, 10, 0):
for module, line_before, line_after in [
("handler_formatting_with_context_manager.py", 17, 16),
("message_formatting_with_context_manager.py", 13, 10),
]:
if module not in exception:
continue
expression = r"^(__main__ %s a) %d\n" % (module, line_before)
exception = re.sub(expression, r"\1 %d\n" % line_after, exception)

exception = re.sub(
r'"[^"]*/somelib/__init__.py"', '"/usr/lib/python/somelib/__init__.py"', exception
)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
skip_missing_interpreters = True
envlist = py{35,36,37,38,39,py3}
envlist = py{35,36,37,38,39,310,py3}

[testenv]
setenv = PYTHONPATH = {toxinidir}
Expand Down

0 comments on commit f2d5133

Please sign in to comment.