-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for unittest with
testscenarios
(microsoft/vscode-python#23230)
Fixes microsoft/vscode-python#17641 --------- Co-authored-by: eleanorjboyd <[email protected]>
- Loading branch information
1 parent
fe63098
commit d457250
Showing
5 changed files
with
95 additions
and
13 deletions.
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 |
---|---|---|
|
@@ -12,6 +12,8 @@ flask | |
fastapi | ||
uvicorn | ||
django | ||
testresources | ||
testscenarios | ||
|
||
# Integrated TensorBoard tests | ||
tensorboard | ||
|
15 changes: 15 additions & 0 deletions
15
...positron-python/python_files/tests/unittestadapter/.data/test_scenarios/tests/__init__.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,15 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import os | ||
|
||
import testresources | ||
from testscenarios import generate_scenarios | ||
|
||
def load_tests(loader, tests, pattern): | ||
this_dir = os.path.dirname(__file__) | ||
mytests = loader.discover(start_dir=this_dir, pattern=pattern) | ||
result = testresources.OptimisingTestSuite() | ||
result.addTests(generate_scenarios(mytests)) | ||
result.addTests(generate_scenarios(tests)) | ||
return result |
25 changes: 25 additions & 0 deletions
25
...sitron-python/python_files/tests/unittestadapter/.data/test_scenarios/tests/test_scene.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,25 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
from testscenarios import TestWithScenarios | ||
|
||
class TestMathOperations(TestWithScenarios): | ||
scenarios = [ | ||
('add', {'test_id': 'test_add', 'a': 5, 'b': 3, 'expected': 8}), | ||
('subtract', {'test_id': 'test_subtract', 'a': 5, 'b': 3, 'expected': 2}), | ||
('multiply', {'test_id': 'test_multiply', 'a': 5, 'b': 3, 'expected': 15}) | ||
] | ||
a: int = 0 | ||
b: int = 0 | ||
expected: int = 0 | ||
test_id: str = "" | ||
|
||
def test_operations(self): | ||
result = None | ||
if self.test_id == 'test_add': | ||
result = self.a + self.b | ||
elif self.test_id == 'test_subtract': | ||
result = self.a - self.b | ||
elif self.test_id == 'test_multiply': | ||
result = self.a * self.b | ||
self.assertEqual(result, self.expected) |
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