Skip to content

Commit 1693c27

Browse files
authored
test python 3.11 (#1302)
1 parent 19cf49a commit 1693c27

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

.github/workflows/build.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ jobs:
1515
experimental: [false]
1616
python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7", "pypy-3.8"]
1717
# Do not test on Python 3.11 pre-releases since wrapt causes problems: https://github.com/GrahamDumpleton/wrapt/issues/196
18-
# include:
18+
include:
1919
# Only test on a single configuration while there are just pre-releases
20-
# - os: ubuntu-latest
21-
# experimental: true
22-
# python-version: "3.11.0-alpha.3"
20+
- os: ubuntu-latest
21+
experimental: true
22+
python-version: "3.11.0-alpha - 3.11.0"
2323
fail-fast: false
2424
steps:
2525
- uses: actions/checkout@v2
2626
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v2
27+
uses: actions/setup-python@v3
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030
- name: Install dependencies
@@ -44,7 +44,7 @@ jobs:
4444
steps:
4545
- uses: actions/checkout@v2
4646
- name: Set up Python
47-
uses: actions/setup-python@v2
47+
uses: actions/setup-python@v3
4848
with:
4949
python-version: "3.10"
5050
- name: Install dependencies
@@ -78,7 +78,7 @@ jobs:
7878
steps:
7979
- uses: actions/checkout@v2
8080
- name: Set up Python
81-
uses: actions/setup-python@v2
81+
uses: actions/setup-python@v3
8282
with:
8383
python-version: "3.10"
8484
- name: Install dependencies

test/test_viewer.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
import can
3939
from can.viewer import CanViewer, parse_args
40-
40+
from test.config import IS_CI
4141

4242
# Allow the curses module to be missing (e.g. on PyPy on Windows)
4343
try:
@@ -251,9 +251,10 @@ def test_receive(self):
251251
if _id["dt"] == 0:
252252
self.assertEqual(_id["count"], 1)
253253
else:
254-
self.assertTrue(
255-
pytest.approx(_id["dt"], 0.1)
256-
) # dt should be ~0.1 s
254+
if not IS_CI: # do not test timing in CI
255+
assert _id["dt"] == pytest.approx(
256+
0.1, abs=5e-2
257+
) # dt should be ~0.1 s
257258
self.assertEqual(_id["count"], 2)
258259
else:
259260
# Make sure dt is 0
@@ -347,7 +348,7 @@ def test_pack_unpack(self):
347348

348349
raw_data = self.pack_data(CANOPEN_TPDO2 + 1, data_structs, 12.34, 4.5, 6)
349350
parsed_data = CanViewer.unpack_data(CANOPEN_TPDO2 + 1, data_structs, raw_data)
350-
self.assertTrue(pytest.approx(parsed_data, [12.34, 4.5, 6]))
351+
assert parsed_data == pytest.approx([12.34, 4.5, 6])
351352
self.assertTrue(
352353
isinstance(parsed_data[0], float)
353354
and isinstance(parsed_data[1], float)
@@ -356,14 +357,14 @@ def test_pack_unpack(self):
356357

357358
raw_data = self.pack_data(CANOPEN_TPDO3 + 1, data_structs, 123.45, 67.89)
358359
parsed_data = CanViewer.unpack_data(CANOPEN_TPDO3 + 1, data_structs, raw_data)
359-
self.assertTrue(pytest.approx(parsed_data, [123.45, 67.89]))
360+
assert parsed_data == pytest.approx([123.45, 67.89])
360361
self.assertTrue(all(isinstance(d, float) for d in parsed_data))
361362

362363
raw_data = self.pack_data(
363364
CANOPEN_TPDO4 + 1, data_structs, math.pi / 2.0, math.pi
364365
)
365366
parsed_data = CanViewer.unpack_data(CANOPEN_TPDO4 + 1, data_structs, raw_data)
366-
self.assertTrue(pytest.approx(parsed_data, [math.pi / 2.0, math.pi]))
367+
assert parsed_data == pytest.approx([math.pi / 2.0, math.pi])
367368
self.assertTrue(all(isinstance(d, float) for d in parsed_data))
368369

369370
raw_data = self.pack_data(CANOPEN_TPDO1 + 2, data_structs)

tox.ini

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[tox]
2+
isolated_build = true
23

34
[testenv]
45
deps =
5-
pytest==6.2.*,>=6.2.5
6+
pytest==7.1.*,>=7.1.2
67
pytest-timeout==2.0.2
78
pytest-cov==3.0.0
8-
coverage==6.2
9+
coverage==6.3
910
codecov==2.1.12
1011
hypothesis~=6.35.0
1112
pyserial~=3.5

0 commit comments

Comments
 (0)