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.
Return exceptions & skips correctly pytest (#21603)
fixes #21579
- Loading branch information
1 parent
f77a011
commit 049ca8b
Showing
7 changed files
with
180 additions
and
9 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
pythonFiles/tests/pytestadapter/.data/error_raise_exception.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,14 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def raise_fixture(): | ||
raise Exception("Dummy exception") | ||
|
||
|
||
class TestSomething: | ||
def test_a(self, raise_fixture): | ||
assert True |
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,6 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import pytest | ||
|
||
|
||
|
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,30 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import pytest | ||
|
||
# Testing pytest with skipped tests. The first passes, the second three are skipped. | ||
|
||
|
||
def test_something(): # test_marker--test_something | ||
# This tests passes successfully. | ||
assert 1 + 1 == 2 | ||
|
||
|
||
def test_another_thing(): # test_marker--test_another_thing | ||
# Skip this test with a reason. | ||
pytest.skip("Skipping this test for now") | ||
|
||
|
||
@pytest.mark.skip( | ||
reason="Skipping this test as it requires additional setup" # test_marker--test_complex_thing | ||
) | ||
def test_decorator_thing(): | ||
# Skip this test as well, with a reason. This one uses a decorator. | ||
assert True | ||
|
||
|
||
@pytest.mark.skipif(1 < 5, reason="is always true") # test_marker--test_complex_thing_2 | ||
def test_decorator_thing_2(): | ||
# Skip this test as well, with a reason. This one uses a decorator with a condition. | ||
assert True |
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