-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
124 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Test the ways to skip a test using `pytest` | ||
- Skip Mark | ||
- SkipIf Mark | ||
- Skip Exception | ||
- Xfail Mark (Expected Failure) | ||
""" | ||
|
||
import pytest | ||
import unittest | ||
|
||
|
||
@pytest.mark.skip(reason="some reason") | ||
def test_skip_mark(): | ||
assert False | ||
|
||
|
||
@unittest.expectedFailure | ||
@pytest.mark.skipIf(False, reason="some reason") | ||
def test_skipif_false(): | ||
assert False | ||
|
||
|
||
@pytest.mark.skipIf(True, reason="i don't know") | ||
def test_skipif_true(): | ||
assert False | ||
|
||
|
||
def test_skip_throw(): | ||
pytest.skip("it will throw Skipped") | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_should_fail(): | ||
assert False | ||
|
||
|
||
@pytest.mark.xfail(True) | ||
def test_should_fail_on_condition(): | ||
assert False | ||
|
||
|
||
@pytest.mark.xfail(False) | ||
def test_should_fail_on_condition_ignored(): | ||
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