Skip to content

Commit

Permalink
[Track CI] Upgrade Workflow to use Python 3.11.2 & Pytest 7.2.2 (#…
Browse files Browse the repository at this point in the history
…3382)

* Upgraded CI workflow to use Python 3.11.2 and Pytest 7.2.2

* Pinned Pylint version to ~=2.17.1

* Added tomli to test_exercises.py imports.

* Adding in tomli for dependancies.

* Need to use latest build of Black due to Python 3.11 and packaging problems with tomli

* Regenerated test files for exercises failing CI.

* Try removing tomli to see if it fixes CI for Py3.11

* And more version fishing for black, which is the culprit here.

* Regeneraed test files with black 22.3.0, since black 23.3.0 is incompatible with Python 3.11 due to tomli conflicts.

* Trying a different strategy.  Using only 3.11 for the main container.

* Must import tomllib, part of exteded standard lib not core.

* Wrapped tomllib in a try-catch and aliased importing tomli.  Updated requirements to only install tmli on 3.10 and below.

* Forgot to update the imports in the generator.

* Added paasio test changes here, since this changes the CI checker to use Python 3.11.

* Trying a msg= approach.
  • Loading branch information
BethanyG committed Apr 7, 2023
1 parent c865759 commit 6cc4b91
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.10.6
python-version: 3.11.2

- name: Download & Install dependencies
run: |
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
needs: housekeeping
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, 3.10.6]
python-version: [3.7, 3.8, 3.9, 3.10.6, 3.11.2]
steps:
- uses: actions/checkout@v3

Expand All @@ -66,7 +66,7 @@ jobs:
run: pip install dataclasses

- name: Install pytest
run: pip install pytest~=7.1.2
run: pip install pytest~=7.2.2

- name: Check exercises
run: |
Expand Down
11 changes: 9 additions & 2 deletions bin/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
from itertools import chain
import json
from pathlib import Path
import tomli
from typing import List, Any, Dict, Type

# Tomli was subsumed into Python 3.11.x, but was renamed to to tomllib.
# This avoids ci failures for Python < 3.11.2.
try:
import tomllib
except ModuleNotFoundError:
import tomli as tomllib



def _custom_dataclass_init(self, *args, **kwargs):
# print(self.__class__.__name__, "__init__")
Expand Down Expand Up @@ -355,7 +362,7 @@ class TestsTOML:
@classmethod
def load(cls, toml_path: Path):
with toml_path.open("rb") as f:
data = tomli.load(f)
data = tomllib.load(f)
return cls({uuid: TestCaseTOML(uuid, *opts) for
uuid, opts in
data.items() if
Expand Down
8 changes: 7 additions & 1 deletion bin/generate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@
from itertools import repeat
from string import punctuation, whitespace
from subprocess import check_call
import tomli
from tempfile import NamedTemporaryFile
from textwrap import wrap
from typing import Any, Dict, List, NoReturn, Union

# Tomli was subsumed into Python 3.11.x, but was renamed to to tomllib.
# This avoids ci failures for Python < 3.11.2.
try:
import tomllib
except ModuleNotFoundError:
import tomli as tomllib

from jinja2 import Environment, FileSystemLoader, TemplateNotFound, UndefinedError
from dateutil.parser import parse

Expand Down
20 changes: 8 additions & 12 deletions exercises/practice/paasio/paasio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ def test_meteredsocket_stats_read_only(self):
self.assertEqual(282, socket.send_bytes)
self.assertEqual(258, socket.recv_ops)
self.assertEqual(259, socket.recv_bytes)
with self.assertRaisesRegex(AttributeError, "can't set"):
with self.assertRaises(AttributeError, msg="property 'send_ops' of 'MeteredSocket' object has no setter"):
socket.send_ops = 0
with self.assertRaisesRegex(AttributeError, "can't set"):
with self.assertRaises(AttributeError, msg="property 'send_bytes' of 'MeteredSocket' object has no setter"):
socket.send_bytes = 0
with self.assertRaisesRegex(AttributeError, "can't set"):
with self.assertRaises(AttributeError, msg="property 'recv_ops' of 'MeteredSocket' object has no setter"):
socket.recv_ops = 0
with self.assertRaisesRegex(AttributeError, "can't set"):
with self.assertRaises(AttributeError, msg="property 'recv_bytes' of 'MeteredSocket' object has no setter"):
socket.recv_bytes = 0
self.assertEqual(278, socket.send_ops)
self.assertEqual(282, socket.send_bytes)
Expand Down Expand Up @@ -426,19 +426,15 @@ def test_meteredfile_stats_read_only(self, super_mock):
file.write(b"bytes")
self.assertEqual(78, file.write_ops)
self.assertEqual(82, file.write_bytes)
with self.assertRaisesRegex(AttributeError, "can't set"):
with self.assertRaises(AttributeError, msg="property 'write_ops' of 'MeteredFile' object has no setter"):
file.write_ops = 0
with self.assertRaisesRegex(AttributeError, "can't set"):
with self.assertRaises(AttributeError, msg="property 'write_bytes' of 'MeteredFile' object has no setter"):
file.write_bytes = 0
with self.assertRaisesRegex(AttributeError, "can't set"):
with self.assertRaises(AttributeError, msg="property 'read_ops' of 'MeteredFile' object has no setter"):
file.read_ops = 0
with self.assertRaisesRegex(AttributeError, "can't set"):
with self.assertRaises(AttributeError, msg="property 'read_bytes' of 'MeteredFile' object has no setter"):
file.read_bytes = 0
self.assertEqual(78, file.write_ops)
self.assertEqual(82, file.write_bytes)
self.assertEqual(58, file.read_ops)
self.assertEqual(59, file.read_bytes)


if __name__ == "__main__":
unittest.main()
4 changes: 2 additions & 2 deletions requirements-generator.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
black==22.3.0
black<=22.3.0
flake8~=5.0.4
Jinja2~=3.1.2
python-dateutil==2.8.1
markupsafe==2.0.1
tomli~=2.0.1
tomli>=1.1.0; python_full_version < '3.11.2'
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
astroid<=2.12.0
flake8~=5.0.4
pylint~=2.14.5
pylint~=2.17.1
black<=22.3.0
yapf~=0.32.0
tomli~=2.0.1
tomli>=1.1.0; python_full_version < '3.11.2'

0 comments on commit 6cc4b91

Please sign in to comment.