Skip to content

Commit 7a5d952

Browse files
authored
[Python 3.11.2 Upgrade] Updated Dockerfile and Requirements (#112)
* Updated dockerfile and requirements to support python 3.11. Regenerated some golden files to match new 3.11 output. * Removed bin/bash entrypoint. * Added tomli versioning, just to be safe. * Adjusted runner to trim subtest noise and regenerated three test files.
1 parent c7677cd commit 7a5d952

File tree

8 files changed

+19
-21
lines changed

8 files changed

+19
-21
lines changed

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10.6-slim
1+
FROM python:3.11.2-slim
22

33
COPY requirements.txt /requirements.txt
44

@@ -15,4 +15,3 @@ COPY . /opt/test-runner
1515
WORKDIR /opt/test-runner
1616

1717
ENTRYPOINT [ "/opt/test-runner/bin/run.sh" ]
18-

pytest.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
[pytest]
2+
addopts =
3+
--color=no
24
norecursedirs =
35
.git .github example* traceback-styles*
46
cache_dir =
57
/tmp/python_cache_dir
68
markers =
79
task: A concept exercise task.
10+
console_output_style =
11+
classic

requirements.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
pytest~=7.1.2
2-
pytest-subtests~=0.5.0
3-
tomli~=2.0.1
1+
black<=22.3.0
2+
pytest~=7.2.2
3+
pytest-subtests~=0.10.0
4+
tomli>=1.1.0; python_full_version < '3.11.2'

runner/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def pytest_runtest_logreport(self, report):
6565

6666
# Update tests that have already failed with capstdout and return.
6767
if not state.is_passing():
68-
if report.capstdout.rstrip('FFFFFFFF '):
69-
state.output = report.capstdout.rstrip('FFFFFFFF ')
68+
if report.capstdout.rstrip('FFFFFFFF ').rstrip('uuuuu'):
69+
state.output = report.capstdout.rstrip('FFFFFFFF ').rstrip('uuuuu')
7070
return
7171

7272
# Record captured relevant stdout content for passed tests.

test/example-empty-file/results.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 3,
33
"status": "error",
4-
"message": " ImportError while importing test module './test/example-empty-file/example_empty_file_test.py'.\nHint: make sure your test modules/packages have valid Python names.\nTraceback:\n/usr/local/lib/python3.10/importlib/__init__.py:126: in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\ntest/example-empty-file/example_empty_file_test.py:4: in <module>\n from example_empty_file import hello\nE ImportError: cannot import name 'hello' from 'example_empty_file' (./test/example-empty-file/example_empty_file.py)",
4+
"message": " ImportError while importing test module './test/example-empty-file/example_empty_file_test.py'.\nHint: make sure your test modules/packages have valid Python names.\nTraceback:\n/usr/local/lib/python3.11/importlib/__init__.py:126: in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\ntest/example-empty-file/example_empty_file_test.py:4: in <module>\n from example_empty_file import hello\nE ImportError: cannot import name 'hello' from 'example_empty_file' (./test/example-empty-file/example_empty_file.py)",
55
"tests": []
6-
}
6+
}

test/example-has-stdout-and-tasks-and-subtests/results.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/example-has-stdout-tasks-and-subtests/results.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"message": "One or more variations of this test failed. Details can be found under each [variant#].",
99
"test_code": "input_data = [1, 2, 5, 10, 15, 23, 33, 39]\nresult_data = [(\"Hello, World!\", param) for param in input_data]\nnumber_of_variants = range(1, len(input_data) + 1)\n\nfor variant, param, result in zip(number_of_variants, input_data, result_data):\n with self.subTest(f\"variation #{variant}\", param=param, result=result):\n self.assertEqual(hello(param), result,\n msg=f'Expected: {result} but got something else instead.')",
1010
"task_id": 1,
11-
"output": "Hello, World! 1\nHello, World! 2\nHello, World! 5\nHello, World! 10\nHello, World! 15\nHello, World! 23\nHello, World! 33\nHello, World! 39"
11+
"output": "Hello, World! 1\nuHello, World! 2\nuHello, World! 5\nuHello, World! 10\nuHello, World! 15\nuHello, World! 23\nuHello, World! 33\nuHello, World! 39"
1212
},
1313
{
1414
"name": "ExampleHasStdout > hello [variation #1] (param=1, result=('Hello, World!', 1))",
@@ -72,7 +72,7 @@
7272
"message": "One or more variations of this test failed. Details can be found under each [variant#].",
7373
"test_code": "input_data = ['frog', 'fish', 'coconut', 'pineapple', 'carrot', 'cucumber', 'grass', 'tree']\nresult_data = [(\"Hello, World!\", param) for param in input_data]\nnumber_of_variants = range(1, len(input_data) + 1)\n\nfor variant, param, result in zip(number_of_variants, input_data, result_data):\n with self.subTest(f\"variation #{variant}\", param=param, result=result):\n self.assertEqual(hello(param), result,\n msg=f'Expected: {result} but got something else instead.')",
7474
"task_id": 2,
75-
"output": "Hello, World! frog\nHello, World! fish\nHello, World! coconut\nHello, World! pineapple\nHello, World! carrot\nHello, World! cucumber\nHello, World! grass\nHello, World! tree"
75+
"output": "Hello, World! frog\nuHello, World! fish\nuHello, World! coconut\nuHello, World! pineapple\nuHello, World! carrot\nuHello, World! cucumber\nuHello, World! grass\nuHello, World! tree"
7676
},
7777
{
7878
"name": "ExampleHasStdout > abc [variation #1] (param='frog', result=('Hello, World!', 'frog'))",
@@ -144,7 +144,7 @@
144144
"message": "One or more variations of this test failed. Details can be found under each [variant#].",
145145
"test_code": "input_data = ['frog', 'fish', 'coconut', 'pineapple', 'carrot', 'cucumber', 'grass', 'tree']\nresult_data = [(\"Hello, World!\", param) for param in input_data]\nnumber_of_variants = range(1, len(input_data) + 1)\n\nfor variant, param, result in zip(number_of_variants, input_data, result_data):\n with self.subTest(f\"variation #{variant}\", param=param, result=result):\n self.assertEqual(hello(param), result,\n msg=f'Expected: {result} but got something else instead.')",
146146
"task_id": 4,
147-
"output": "Hello, World! frog\nHello, World! fish\nHello, World! coconut\nHello, World! pineapple\nHello, World! carrot\nHello, World! cucumber\nHello, World! grass\nHello, World! tree"
147+
"output": "Hello, World! frog\nuHello, World! fish\nuHello, World! coconut\nuHello, World! pineapple\nuHello, World! carrot\nuHello, World! cucumber\nuHello, World! grass\nuHello, World! tree"
148148
},
149149
{
150150
"name": "ExampleHasStdoutOther > dummy [variation #1] (param='frog', result=('Hello, World!', 'frog'))",
@@ -208,7 +208,7 @@
208208
"message": "One or more variations of this test failed. Details can be found under each [variant#].",
209209
"test_code": "input_data = [1, 2, 5, 10, 15, 23, 33, 39]\nresult_data = [(\"Hello, World!\", param) for param in input_data]\nnumber_of_variants = range(1, len(input_data) + 1)\n\nfor variant, param, result in zip(number_of_variants, input_data, result_data):\n with self.subTest(f\"variation #{variant}\", param=param, result=result):\n self.assertEqual(hello(param), result,\n msg=f'Expected: {result} but got something else instead.')",
210210
"task_id": 5,
211-
"output": "Hello, World! 1\nHello, World! 2\nHello, World! 5\nHello, World! 10\nHello, World! 15\nHello, World! 23\nHello, World! 33\nHello, World! 39"
211+
"output": "Hello, World! 1\nuHello, World! 2\nuHello, World! 5\nuHello, World! 10\nuHello, World! 15\nuHello, World! 23\nuHello, World! 33\nuHello, World! 39"
212212
},
213213
{
214214
"name": "ExampleHasStdoutOther > hello [variation #1] (param=1, result=('Hello, World!', 1))",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 3,
33
"status": "error",
4-
"message": " /usr/local/lib/python3.10/site-packages/_pytest/python.py:608: in _importtestmodule\n mod = import_path(self.path, mode=importmode, root=self.config.rootpath)\n/usr/local/lib/python3.10/site-packages/_pytest/pathlib.py:533: in import_path\n importlib.import_module(module_name)\n/usr/local/lib/python3.10/importlib/__init__.py:126: in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n<frozen importlib._bootstrap>:1050: in _gcd_import\n ???\n<frozen importlib._bootstrap>:1027: in _find_and_load\n ???\n<frozen importlib._bootstrap>:1006: in _find_and_load_unlocked\n ???\n<frozen importlib._bootstrap>:688: in _load_unlocked\n ???\n/usr/local/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:168: in exec_module\n exec(co, module.__dict__)\ntest/example-syntax-error/example_syntax_error_test.py:4: in <module>\n from example_syntax_error import hello\nE File \"./test/example-syntax-error/example_syntax_error.py\", line 3\nE def hello();\nE ^\nE SyntaxError: expected ':'",
4+
"message": " /usr/local/lib/python3.11/site-packages/_pytest/python.py:618: in _importtestmodule\n mod = import_path(self.path, mode=importmode, root=self.config.rootpath)\n/usr/local/lib/python3.11/site-packages/_pytest/pathlib.py:533: in import_path\n importlib.import_module(module_name)\n/usr/local/lib/python3.11/importlib/__init__.py:126: in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n<frozen importlib._bootstrap>:1206: in _gcd_import\n ???\n<frozen importlib._bootstrap>:1178: in _find_and_load\n ???\n<frozen importlib._bootstrap>:1149: in _find_and_load_unlocked\n ???\n<frozen importlib._bootstrap>:690: in _load_unlocked\n ???\n/usr/local/lib/python3.11/site-packages/_pytest/assertion/rewrite.py:168: in exec_module\n exec(co, module.__dict__)\ntest/example-syntax-error/example_syntax_error_test.py:4: in <module>\n from example_syntax_error import hello\nE File \"./test/example-syntax-error/example_syntax_error.py\", line 3\nE def hello();\nE ^\nE SyntaxError: expected ':'",
55
"tests": []
6-
}
6+
}

0 commit comments

Comments
 (0)