Skip to content

Commit

Permalink
[Python 3.11.2 Upgrade] Updated Dockerfile and Requirements (#112)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
BethanyG authored Apr 7, 2023
1 parent c7677cd commit 7a5d952
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 21 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10.6-slim
FROM python:3.11.2-slim

COPY requirements.txt /requirements.txt

Expand All @@ -15,4 +15,3 @@ COPY . /opt/test-runner
WORKDIR /opt/test-runner

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

4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[pytest]
addopts =
--color=no
norecursedirs =
.git .github example* traceback-styles*
cache_dir =
/tmp/python_cache_dir
markers =
task: A concept exercise task.
console_output_style =
classic
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pytest~=7.1.2
pytest-subtests~=0.5.0
tomli~=2.0.1
black<=22.3.0
pytest~=7.2.2
pytest-subtests~=0.10.0
tomli>=1.1.0; python_full_version < '3.11.2'
4 changes: 2 additions & 2 deletions runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def pytest_runtest_logreport(self, report):

# Update tests that have already failed with capstdout and return.
if not state.is_passing():
if report.capstdout.rstrip('FFFFFFFF '):
state.output = report.capstdout.rstrip('FFFFFFFF ')
if report.capstdout.rstrip('FFFFFFFF ').rstrip('uuuuu'):
state.output = report.capstdout.rstrip('FFFFFFFF ').rstrip('uuuuu')
return

# Record captured relevant stdout content for passed tests.
Expand Down
4 changes: 2 additions & 2 deletions test/example-empty-file/results.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 3,
"status": "error",
"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)",
"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)",
"tests": []
}
}
6 changes: 0 additions & 6 deletions test/example-has-stdout-and-tasks-and-subtests/results.json

This file was deleted.

8 changes: 4 additions & 4 deletions test/example-has-stdout-tasks-and-subtests/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"message": "One or more variations of this test failed. Details can be found under each [variant#].",
"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.')",
"task_id": 1,
"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"
"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"
},
{
"name": "ExampleHasStdout > hello [variation #1] (param=1, result=('Hello, World!', 1))",
Expand Down Expand Up @@ -72,7 +72,7 @@
"message": "One or more variations of this test failed. Details can be found under each [variant#].",
"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.')",
"task_id": 2,
"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"
"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"
},
{
"name": "ExampleHasStdout > abc [variation #1] (param='frog', result=('Hello, World!', 'frog'))",
Expand Down Expand Up @@ -144,7 +144,7 @@
"message": "One or more variations of this test failed. Details can be found under each [variant#].",
"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.')",
"task_id": 4,
"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"
"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"
},
{
"name": "ExampleHasStdoutOther > dummy [variation #1] (param='frog', result=('Hello, World!', 'frog'))",
Expand Down Expand Up @@ -208,7 +208,7 @@
"message": "One or more variations of this test failed. Details can be found under each [variant#].",
"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.')",
"task_id": 5,
"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"
"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"
},
{
"name": "ExampleHasStdoutOther > hello [variation #1] (param=1, result=('Hello, World!', 1))",
Expand Down
4 changes: 2 additions & 2 deletions test/example-syntax-error/results.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 3,
"status": "error",
"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 ':'",
"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 ':'",
"tests": []
}
}

0 comments on commit 7a5d952

Please sign in to comment.