pytest-exit-code 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytest-exit-code
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A pytest plugin that overrides the built-in exit codes to retain more information about the test results.
5
5
  Author-email: Sander Ploegsma <sanderploegsma@gmail.com>
6
6
  Maintainer-email: Sander Ploegsma <sanderploegsma@gmail.com>
@@ -235,7 +235,7 @@ A [pytest] plugin that overrides the built-in exit codes to retain more informat
235
235
  ## Features
236
236
 
237
237
  This plugin changes the exit code returned by running `pytest`.
238
- The exit codes can range from `0` to `15` and are a combination of the following bitwise flags:
238
+ The exit codes can range from `0` to `63` and are a combination of the following bitwise flags:
239
239
 
240
240
  | Flag | Description |
241
241
  | ---- | ------------------------------- |
@@ -244,6 +244,8 @@ The exit codes can range from `0` to `15` and are a combination of the following
244
244
  | `2` | One or more tests failed. |
245
245
  | `4` | One or more tests errored. |
246
246
  | `8` | One or more tests were skipped. |
247
+ | `16` | One or more tests xfailed. |
248
+ | `32` | One or more tests xpassed. |
247
249
 
248
250
  So:
249
251
 
@@ -5,7 +5,7 @@ A [pytest] plugin that overrides the built-in exit codes to retain more informat
5
5
  ## Features
6
6
 
7
7
  This plugin changes the exit code returned by running `pytest`.
8
- The exit codes can range from `0` to `15` and are a combination of the following bitwise flags:
8
+ The exit codes can range from `0` to `63` and are a combination of the following bitwise flags:
9
9
 
10
10
  | Flag | Description |
11
11
  | ---- | ------------------------------- |
@@ -14,6 +14,8 @@ The exit codes can range from `0` to `15` and are a combination of the following
14
14
  | `2` | One or more tests failed. |
15
15
  | `4` | One or more tests errored. |
16
16
  | `8` | One or more tests were skipped. |
17
+ | `16` | One or more tests xfailed. |
18
+ | `32` | One or more tests xpassed. |
17
19
 
18
20
  So:
19
21
 
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "pytest-exit-code"
7
7
  description = "A pytest plugin that overrides the built-in exit codes to retain more information about the test results."
8
- version = "0.1.0"
8
+ version = "0.2.0"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
11
11
  authors = [{ name = "Sander Ploegsma", email = "sanderploegsma@gmail.com" }]
@@ -7,3 +7,5 @@ class ExitCode(IntFlag):
7
7
  TESTS_FAILED = 2
8
8
  TESTS_ERRORED = 4
9
9
  TESTS_SKIPPED = 8
10
+ TESTS_XFAILED = 16
11
+ TESTS_XPASSED = 32
@@ -12,7 +12,10 @@ class ExitCodePlugin:
12
12
  @pytest.hookimpl
13
13
  def pytest_runtest_logreport(self, report: pytest.TestReport) -> None:
14
14
  if report.passed and report.when in ["call"]:
15
- self.exit_code |= ExitCode.TESTS_PASSED
15
+ if hasattr(report, "wasxfail"):
16
+ self.exit_code |= ExitCode.TESTS_XPASSED
17
+ else:
18
+ self.exit_code |= ExitCode.TESTS_PASSED
16
19
 
17
20
  if report.failed:
18
21
  if report.when in ["setup", "teardown"]:
@@ -21,7 +24,10 @@ class ExitCodePlugin:
21
24
  self.exit_code |= ExitCode.TESTS_FAILED
22
25
 
23
26
  if report.skipped:
24
- self.exit_code |= ExitCode.TESTS_SKIPPED
27
+ if hasattr(report, "wasxfail"):
28
+ self.exit_code |= ExitCode.TESTS_XFAILED
29
+ else:
30
+ self.exit_code |= ExitCode.TESTS_SKIPPED
25
31
 
26
32
  @pytest.hookimpl
27
33
  def pytest_sessionfinish(self, session: pytest.Session):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytest-exit-code
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A pytest plugin that overrides the built-in exit codes to retain more information about the test results.
5
5
  Author-email: Sander Ploegsma <sanderploegsma@gmail.com>
6
6
  Maintainer-email: Sander Ploegsma <sanderploegsma@gmail.com>
@@ -235,7 +235,7 @@ A [pytest] plugin that overrides the built-in exit codes to retain more informat
235
235
  ## Features
236
236
 
237
237
  This plugin changes the exit code returned by running `pytest`.
238
- The exit codes can range from `0` to `15` and are a combination of the following bitwise flags:
238
+ The exit codes can range from `0` to `63` and are a combination of the following bitwise flags:
239
239
 
240
240
  | Flag | Description |
241
241
  | ---- | ------------------------------- |
@@ -244,6 +244,8 @@ The exit codes can range from `0` to `15` and are a combination of the following
244
244
  | `2` | One or more tests failed. |
245
245
  | `4` | One or more tests errored. |
246
246
  | `8` | One or more tests were skipped. |
247
+ | `16` | One or more tests xfailed. |
248
+ | `32` | One or more tests xpassed. |
247
249
 
248
250
  So:
249
251
 
@@ -1,5 +1,4 @@
1
1
  import pytest
2
-
3
2
  from pytest_exit_code import ExitCode
4
3
 
5
4
 
@@ -10,12 +9,17 @@ from pytest_exit_code import ExitCode
10
9
  ("test_fail", ExitCode.TESTS_FAILED),
11
10
  ("test_error", ExitCode.TESTS_ERRORED),
12
11
  ("test_skip", ExitCode.TESTS_SKIPPED),
12
+ ("test_xfail", ExitCode.TESTS_XFAILED),
13
+ ("test_xpass", ExitCode.TESTS_XPASSED),
14
+ ("test_strict_xfail", ExitCode.TESTS_FAILED),
13
15
  (
14
16
  "",
15
17
  ExitCode.TESTS_PASSED
16
18
  | ExitCode.TESTS_FAILED
17
19
  | ExitCode.TESTS_ERRORED
18
- | ExitCode.TESTS_SKIPPED,
20
+ | ExitCode.TESTS_SKIPPED
21
+ | ExitCode.TESTS_XFAILED
22
+ | ExitCode.TESTS_XPASSED,
19
23
  ),
20
24
  ("test_unknown", ExitCode.ALL_PASSED),
21
25
  ],
@@ -45,6 +49,18 @@ def test_correct_exit_codes(
45
49
  @pytest.mark.skip
46
50
  def test_skip():
47
51
  assert 1 == 1
52
+
53
+ @pytest.mark.xfail
54
+ def test_xfail():
55
+ raise RuntimeError("Failure in test")
56
+
57
+ @pytest.mark.xfail
58
+ def test_xpass():
59
+ assert 1 == 1
60
+
61
+ @pytest.mark.xfail(strict=True)
62
+ def test_strict_xfail():
63
+ assert 1 == 1
48
64
  """
49
65
  )
50
66