forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand Testing for Unittest Run in PythonFiles (#21028)
closes #21031
- Loading branch information
1 parent
81debac
commit b4f0ad1
Showing
8 changed files
with
284 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
pythonFiles/tests/unittestadapter/.data/test_fail_simple.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 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import unittest | ||
|
||
# Test class for the test_fail_simple test. | ||
# The test_failed_tests function should return a dictionary with a "success" status | ||
# and the two tests with their outcome as "failed". | ||
|
||
class RunFailSimple(unittest.TestCase): | ||
"""Test class for the test_fail_simple test. | ||
The test_failed_tests function should return a dictionary with a "success" status | ||
and the two tests with their outcome as "failed". | ||
""" | ||
|
||
def test_one_fail(self) -> None: | ||
self.assertGreater(2, 3) | ||
|
||
def test_two_fail(self) -> None: | ||
self.assertNotEqual(1, 1) |
20 changes: 20 additions & 0 deletions
20
pythonFiles/tests/unittestadapter/.data/test_two_classes.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,20 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import unittest | ||
|
||
# Test class which runs for the test_multiple_ids_run test with the two class parameters. | ||
# Both test functions will be returned in a dictionary with a "success" status, | ||
# and the two tests with their outcome as "success". | ||
|
||
|
||
class ClassOne(unittest.TestCase): | ||
|
||
def test_one(self) -> None: | ||
self.assertGreater(2, 1) | ||
|
||
class ClassTwo(unittest.TestCase): | ||
|
||
def test_two(self) -> None: | ||
self.assertGreater(2, 1) | ||
|
22 changes: 22 additions & 0 deletions
22
pythonFiles/tests/unittestadapter/.data/two_patterns/pattern_a_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,22 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
import unittest | ||
|
||
# Test class for the two file pattern test. It is pattern *test.py. | ||
# The test_ids_multiple_runs function should return a dictionary with a "success" status, | ||
# and the two tests with their outcome as "success". | ||
|
||
|
||
|
||
class DiscoveryA(unittest.TestCase): | ||
"""Test class for the two file pattern test. It is pattern *test.py | ||
The test_ids_multiple_runs function should return a dictionary with a "success" status, | ||
and the two tests with their outcome as "success". | ||
""" | ||
|
||
def test_one_a(self) -> None: | ||
self.assertGreater(2, 1) | ||
|
||
def test_two_a(self) -> None: | ||
self.assertNotEqual(2, 1) |
15 changes: 15 additions & 0 deletions
15
pythonFiles/tests/unittestadapter/.data/two_patterns/test_pattern_b.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 unittest | ||
|
||
# Test class for the two file pattern test. This file is pattern test*.py. | ||
# The test_ids_multiple_runs function should return a dictionary with a "success" status, | ||
# and the two tests with their outcome as "success". | ||
|
||
class DiscoveryB(unittest.TestCase): | ||
|
||
def test_one_b(self) -> None: | ||
self.assertGreater(2, 1) | ||
|
||
def test_two_b(self) -> None: | ||
self.assertNotEqual(2, 1) |
22 changes: 22 additions & 0 deletions
22
pythonFiles/tests/unittestadapter/.data/unittest_folder/test_add.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,22 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
import unittest | ||
|
||
# Test class which runs for the test_multiple_ids_run test with the two test | ||
# files in the same folder. The cwd is set to the parent folder. This should return | ||
# a dictionary with a "success" status and the two tests with their outcome as "success". | ||
|
||
def add(a, b): | ||
return a + b | ||
|
||
|
||
class TestAddFunction(unittest.TestCase): | ||
|
||
def test_add_positive_numbers(self): | ||
result = add(2, 3) | ||
self.assertEqual(result, 5) | ||
|
||
|
||
def test_add_negative_numbers(self): | ||
result = add(-2, -3) | ||
self.assertEqual(result, -5) |
21 changes: 21 additions & 0 deletions
21
pythonFiles/tests/unittestadapter/.data/unittest_folder/test_subtract.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 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
import unittest | ||
|
||
# Test class which runs for the test_multiple_ids_run test with the two test | ||
# files in the same folder. The cwd is set to the parent folder. This should return | ||
# a dictionary with a "success" status and the two tests with their outcome as "success". | ||
|
||
def subtract(a, b): | ||
return a - b | ||
|
||
|
||
class TestSubtractFunction(unittest.TestCase): | ||
def test_subtract_positive_numbers(self): | ||
result = subtract(5, 3) | ||
self.assertEqual(result, 2) | ||
|
||
|
||
def test_subtract_negative_numbers(self): | ||
result = subtract(-2, -3) | ||
self.assertEqual(result, 1) |
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