-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added task_id to Tests and Test Reports #65
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
86b5301
Added task mark for flagging tests with exercise tasks.
BethanyG 8edee75
Added code to retrieve pytest.mark and add the value to test and subt…
BethanyG 0d298ca
Added task parameter to Test object.
BethanyG d219458
Added task parameter to Test object.
BethanyG f47532f
Re-generated golden files with task_id.
BethanyG 2c1f7fd
Added golden file and tests for stdout with flagged exercises tasks.
BethanyG b805a8c
Added golden file and tests for tests that use subtest and task flags.
BethanyG 281aa81
Added success golden files and tests for tests flagged with exercise …
BethanyG 04678c7
Removed print statement in example file.
BethanyG a522025
Regenerated resluts.json for partial failure test case.
BethanyG 708cdae
regenerated results.json for success with subtests and partial faiure…
BethanyG ca0ddf9
Edited example file to omit the stdout (print) line.
BethanyG 34e2330
regenerated example-has-stdout-and-tasks using run-in-docker script.
BethanyG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
[pytest] | ||
norecursedirs = .git .github example* traceback-styles* | ||
cache_dir = /tmp/python_cache_dir | ||
norecursedirs = | ||
.git .github example* traceback-styles* | ||
cache_dir = | ||
/tmp/python_cache_dir | ||
markers = | ||
task: A concept exercise task. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
{ | ||
"version": 2, | ||
"version": 3, | ||
"status": "fail", | ||
"tests": [ | ||
{ | ||
"name": "ExampleAllFailTest.test_hello", | ||
"status": "fail", | ||
"message": "AssertionError: 'Goodbye!' != 'Hello, World!'\n- Goodbye!\n+ Hello, World!", | ||
"test_code": "self.assertEqual(hello(), \"Hello, World!\")" | ||
"test_code": "self.assertEqual(hello(), \"Hello, World!\")", | ||
"task_id": 0 | ||
}, | ||
{ | ||
"name": "ExampleAllFailTest.test_abc", | ||
"status": "fail", | ||
"message": "AssertionError: 'Goodbye!' != 'Hello, World!'\n- Goodbye!\n+ Hello, World!", | ||
"test_code": "self.assertEqual(hello(), \"Hello, World!\")" | ||
"test_code": "self.assertEqual(hello(), \"Hello, World!\")", | ||
"task_id": 0 | ||
}, | ||
{ | ||
"name": "ExampleAllFailOtherTest.test_dummy", | ||
"status": "fail", | ||
"message": "AssertionError: 'Goodbye!' != 'Hello, World!'\n- Goodbye!\n+ Hello, World!", | ||
"test_code": "self.assertEqual(hello(), \"Hello, World!\")" | ||
"test_code": "self.assertEqual(hello(), \"Hello, World!\")", | ||
"task_id": 0 | ||
}, | ||
{ | ||
"name": "ExampleAllFailOtherTest.test_hello", | ||
"status": "fail", | ||
"message": "AssertionError: 'Goodbye!' != 'Hello, World!'\n- Goodbye!\n+ Hello, World!", | ||
"test_code": "self.assertEqual(hello(), \"Hello, World!\")" | ||
"test_code": "self.assertEqual(hello(), \"Hello, World!\")", | ||
"task_id": 0 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test/example-has-stdout-and-tasks/example_has_stdout_and_tasks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Example Exercism/Python solution file""" | ||
|
||
|
||
def hello(): | ||
print("Hello, World!") | ||
|
||
|
||
def must_truncate(): | ||
print( | ||
""" | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vulputate ut pharetra sit amet aliquam. Amet dictum sit amet justo donec enim diam vulputate ut. Consequat nisl vel pretium lectus quam id leo. Maecenas accumsan lacus vel facilisis volutpat est velit egestas dui. Faucibus et molestie ac feugiat sed. Fringilla phasellus faucibus scelerisque eleifend donec pretium vulputate sapien. Nibh venenatis cras sed felis. Tortor at risus viverra adipiscing at. Orci dapibus ultrices in iaculis nunc. In fermentum et sollicitudin ac orci phasellus egestas tellus. Tincidunt lobortis feugiat vivamus at augue eget arcu dictum varius. Volutpat est velit egestas dui id. Non nisi est sit amet facilisis magna etiam tempor. Tincidunt id aliquet risus feugiat in ante metus dictum. Viverra aliquet eget sit amet tellus cras adipiscing. Arcu dictum varius duis at. Aliquet lectus proin nibh nisl. | ||
|
||
Urna molestie at elementum eu. Morbi quis commodo odio aenean. Commodo elit at imperdiet dui accumsan sit amet nulla. Faucibus a pellentesque sit amet porttitor. Donec pretium vulputate sapien nec. Felis eget velit aliquet sagittis id consectetur. Nulla malesuada pellentesque elit eget gravida cum. Mauris augue neque gravida in fermentum et sollicitudin. At quis risus sed vulputate odio ut enim blandit volutpat. Enim blandit volutpat maecenas volutpat blandit. Diam in arcu cursus euismod. Congue nisi vitae suscipit tellus mauris a diam. | ||
|
||
Adipiscing enim eu turpis egestas pretium aenean pharetra magna ac. Et odio pellentesque diam volutpat commodo sed egestas. Nulla porttitor massa id neque aliquam vestibulum morbi blandit cursus. Nisi porta lorem mollis aliquam ut porttitor. Morbi leo urna molestie at elementum eu facilisis. Vel elit scelerisque mauris pellentesque pulvinar. Fames ac turpis egestas maecenas pharetra convallis. Ornare arcu dui vivamus arcu felis bibendum ut tristique et. Blandit massa enim nec dui nunc mattis enim. Elit ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at augue. | ||
|
||
Scelerisque varius morbi enim nunc faucibus a pellentesque sit. Enim diam vulputate ut pharetra. Tempor orci eu lobortis elementum nibh tellus molestie nunc non. Cras pulvinar mattis nunc sed. Ac turpis egestas maecenas pharetra convallis posuere morbi leo. Platea dictumst quisque sagittis purus sit amet. Vitae tortor condimentum lacinia quis vel eros donec ac odio. Viverra nibh cras pulvinar mattis nunc sed blandit. Tincidunt lobortis feugiat vivamus at augue. Duis at consectetur lorem donec massa sapien faucibus. Magna ac placerat vestibulum lectus mauris ultrices. Convallis posuere morbi leo urna molestie at. | ||
|
||
Porta non pulvinar neque laoreet suspendisse interdum consectetur libero. Id faucibus nisl tincidunt eget nullam. Ultricies lacus sed turpis tincidunt id. Hendrerit dolor magna eget est lorem ipsum. Enim ut sem viverra aliquet. Eget nulla facilisi etiam dignissim diam quis enim lobortis scelerisque. Ac tortor dignissim convallis aenean et tortor at. Non tellus orci ac auctor augue. Nec dui nunc mattis enim ut tellus. Eget nunc lobortis mattis aliquam faucibus purus in massa tempor. Elementum nibh tellus molestie nunc. Ornare lectus sit amet est placerat in. Nec feugiat in fermentum posuere urna nec tincidunt praesent. Vestibulum rhoncus est pellentesque elit. Mollis nunc sed id semper risus in. Vitae elementum curabitur vitae nunc sed velit. Duis tristique sollicitudin nibh sit amet commodo nulla facilisi.""" | ||
) | ||
return "Goodbye!" |
35 changes: 35 additions & 0 deletions
35
test/example-has-stdout-and-tasks/example_has_stdout_and_tasks_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import unittest | ||
import pytest | ||
|
||
|
||
from example_has_stdout_and_tasks import hello, must_truncate | ||
|
||
|
||
class ExampleHasStdoutTest(unittest.TestCase): | ||
|
||
@pytest.mark.task(taskno=1) | ||
def test_hello(self): | ||
self.assertEqual(hello(), "Hello, World!") | ||
|
||
@pytest.mark.task(taskno=2) | ||
def test_abc(self): | ||
self.assertEqual(hello(), "Hello, World!") | ||
|
||
@pytest.mark.task(taskno=3) | ||
def test_trancation(self): | ||
self.assertEqual(must_truncate(), "Hello, World!") | ||
|
||
|
||
class ExampleHasStdoutOtherTest(unittest.TestCase): | ||
|
||
@pytest.mark.task(taskno=4) | ||
def test_dummy(self): | ||
self.assertEqual(hello(), "Hello, World!") | ||
|
||
@pytest.mark.task(taskno=5) | ||
def test_hello(self): | ||
self.assertEqual(hello(), "Hello, World!") | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"version": 3, | ||
"status": "fail", | ||
"tests": [ | ||
{ | ||
"name": "ExampleHasStdoutTest.test_abc", | ||
"status": "fail", | ||
"message": "AssertionError: None != 'Hello, World!'", | ||
"test_code": "def test_abc(self):\n self.assertEqual(hello(), \"Hello, World!\")", | ||
"task_id": 2, | ||
"output": "Hello, World!" | ||
}, | ||
{ | ||
"name": "ExampleHasStdoutTest.test_hello", | ||
"status": "fail", | ||
"message": "AssertionError: None != 'Hello, World!'", | ||
"test_code": "def test_hello(self):\n self.assertEqual(hello(), \"Hello, World!\")", | ||
"task_id": 1, | ||
"output": "Hello, World!" | ||
}, | ||
{ | ||
"name": "ExampleHasStdoutTest.test_trancation", | ||
"status": "fail", | ||
"message": "AssertionError: 'Goodbye!' != 'Hello, World!'\n- Goodbye!\n+ Hello, World!", | ||
"test_code": "def test_trancation(self):\n self.assertEqual(must_truncate(), \"Hello, World!\")", | ||
"task_id": 3, | ||
"output": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vulputate ut pharetra sit amet aliquam. Amet dictum sit amet justo donec enim diam vulputate ut. Consequat nisl vel pretium lectus quam id leo. Maecenas accumsan lacus vel facilisis volutpat est velit egestas dui. Faucibus et molestie ac feugiat sed. Fringilla phasellus faucibus scelerisque eleifend donec pretium vulputate s [Output was truncated. Please limit to 500 chars]" | ||
}, | ||
{ | ||
"name": "ExampleHasStdoutOtherTest.test_dummy", | ||
"status": "fail", | ||
"message": "AssertionError: None != 'Hello, World!'", | ||
"test_code": "def test_dummy(self):\n self.assertEqual(hello(), \"Hello, World!\")", | ||
"task_id": 4, | ||
"output": "Hello, World!" | ||
}, | ||
{ | ||
"name": "ExampleHasStdoutOtherTest.test_hello", | ||
"status": "fail", | ||
"message": "AssertionError: None != 'Hello, World!'", | ||
"test_code": "def test_hello(self):\n self.assertEqual(hello(), \"Hello, World!\")", | ||
"task_id": 5, | ||
"output": "Hello, World!" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
{ | ||
"version": 2, | ||
"version": 3, | ||
"status": "fail", | ||
"tests": [ | ||
{ | ||
"name": "ExamplePartialFailTest.test_hello", | ||
"status": "fail", | ||
"message": "AssertionError: 'Hello, World!' != 'Goodbye'\n- Hello, World!\n+ Goodbye", | ||
"test_code": "self.assertEqual(hello(), \"Goodbye\")" | ||
"test_code": "self.assertEqual(hello(), \"Goodbye\")", | ||
"task_id": 0 | ||
}, | ||
{ | ||
"name": "ExamplePartialFailTest.test_abc", | ||
"status": "pass", | ||
"test_code": "self.assertEqual(hello(), \"Hello, World!\")" | ||
"test_code": "self.assertEqual(hello(), \"Hello, World!\")", | ||
"task_id": 0 | ||
}, | ||
{ | ||
"name": "ExamplePartialFailOtherTest.test_dummy", | ||
"status": "fail", | ||
"message": "AssertionError: 'Hello, World!' != 'Goodbye'\n- Hello, World!\n+ Goodbye", | ||
"test_code": "self.assertEqual(hello(), \"Goodbye\")" | ||
"test_code": "self.assertEqual(hello(), \"Goodbye\")", | ||
"task_id": 0 | ||
}, | ||
{ | ||
"name": "ExamplePartialFailOtherTest.test_hello", | ||
"status": "pass", | ||
"test_code": "self.assertEqual(hello(), \"Hello, World!\")" | ||
"test_code": "self.assertEqual(hello(), \"Hello, World!\")", | ||
"task_id": 0 | ||
} | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
test/example-partial-failure-with-subtests/example_partial_failure_with_subtests.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"""Example Exercism/Python solution file""" | ||
|
||
|
||
def hello(param): | ||
if isinstance(param, int): | ||
return ("Hello, World!") | ||
else: | ||
return ("Hello, World!", param) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the subtests module not already do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣 No. The subtests module makes it possible to use
subttest
without PyTest freaking out. There is actually an ongoing discussion on thepytest-subtest
repo on how to handle failures and test counting right now. And - as the discussion outlines - this is actually behavior inherited fromunittest
. So for our plugin, I decided to make it "cleaner". But it is still weird to have a count mis-match when all tests pass vs when some that have sub-tests fail (this happens with all parameterization, in Unittest/Pytest if I am remembering correctly).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...I'd actually love to do a refactor of our runner that treats parameterization more like a matrix -- so that there is a clean count of which tests are parameterized, then a process that "explodes" the matrix into individual cases, then makes a summary. But I don't think we want to do that right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No probably right now, but that sounds like a good idea.