pytest-api-core 1.1.0__tar.gz → 1.1.1__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.
Files changed (34) hide show
  1. {pytest_api_core-1.1.0/src/pytest_api_core.egg-info → pytest_api_core-1.1.1}/PKG-INFO +22 -3
  2. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/README.md +21 -2
  3. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/pyproject.toml +1 -1
  4. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/__init__.py +1 -1
  5. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/assertions/soft.py +32 -17
  6. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/reporters/templates/report.html +4 -3
  7. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/security/redaction.py +11 -1
  8. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1/src/pytest_api_core.egg-info}/PKG-INFO +22 -3
  9. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/LICENSE +0 -0
  10. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/MANIFEST.in +0 -0
  11. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/setup.cfg +0 -0
  12. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/assertions/__init__.py +0 -0
  13. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/assertions/assert_utils.py +0 -0
  14. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/assertions/response_assertions.py +0 -0
  15. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/auth/__init__.py +0 -0
  16. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/auth/auth_handlers.py +0 -0
  17. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/client/__init__.py +0 -0
  18. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/client/api_client.py +0 -0
  19. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/client/api_response.py +0 -0
  20. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/config/__init__.py +0 -0
  21. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/config/base_settings.py +0 -0
  22. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/config/config_manager.py +0 -0
  23. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/config/env_loader.py +0 -0
  24. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/fixtures/__init__.py +0 -0
  25. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/fixtures/api_fixtures.py +0 -0
  26. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/plugin.py +0 -0
  27. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/reporters/__init__.py +0 -0
  28. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/reporters/html_reporter.py +0 -0
  29. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core/security/__init__.py +0 -0
  30. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core.egg-info/SOURCES.txt +0 -0
  31. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core.egg-info/dependency_links.txt +0 -0
  32. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core.egg-info/entry_points.txt +0 -0
  33. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core.egg-info/requires.txt +0 -0
  34. {pytest_api_core-1.1.0 → pytest_api_core-1.1.1}/src/pytest_api_core.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-api-core
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: Pytest API automation framework with custom HTML reporting, reusable fixtures, and fluent assertions
5
5
  Author: QA Platform Team
6
6
  License: MIT License
@@ -92,16 +92,35 @@ Dynamic: license-file
92
92
 
93
93
  ---
94
94
 
95
+ ## Report preview
96
+
97
+ One self-contained HTML file per run (`--api-html-report=reports/report_{timestamp}.html`).
98
+ Browse real ones from this repo's CI on the [live reports dashboard](https://githubreports.apicore.subodhsingh.in/).
99
+
100
+ **Run summary and per-endpoint latency**
101
+
102
+ ![Report overview: pass/fail summary, endpoint performance table with p50/p95 latency, and the filterable results table](https://raw.githubusercontent.com/sksingh329/pytest-api-core-framework/develop/docs/images/report-overview.png)
103
+
104
+ **Every assertion as its own row** — here inside `soft_assertions()`, so all three failures are reported in one run, as one error pointing at the test's own code
105
+
106
+ ![Expanded failed test showing a PATCH request banner, assertion rows with path, expected and actual values, and a single combined soft-assertion failure](https://raw.githubusercontent.com/sksingh329/pytest-api-core-framework/develop/docs/images/report-assertions.png)
107
+
108
+ **Request details, redacted secrets, Copy cURL, and timeouts shown as ERROR**
109
+
110
+ ![Expanded tests showing a token response with the access token redacted, and a request that timed out shown with a red ERROR banner](https://raw.githubusercontent.com/sksingh329/pytest-api-core-framework/develop/docs/images/report-requests.png)
111
+
112
+ ---
113
+
95
114
  ## Installation
96
115
 
97
116
  ```bash
98
- pip install pytest-api-core==1.1.0
117
+ pip install pytest-api-core==1.1.1
99
118
  ```
100
119
 
101
120
  With `.env` file support (recommended):
102
121
 
103
122
  ```bash
104
- pip install "pytest-api-core[dotenv]==1.1.0"
123
+ pip install "pytest-api-core[dotenv]==1.1.1"
105
124
  ```
106
125
 
107
126
  ---
@@ -26,16 +26,35 @@
26
26
 
27
27
  ---
28
28
 
29
+ ## Report preview
30
+
31
+ One self-contained HTML file per run (`--api-html-report=reports/report_{timestamp}.html`).
32
+ Browse real ones from this repo's CI on the [live reports dashboard](https://githubreports.apicore.subodhsingh.in/).
33
+
34
+ **Run summary and per-endpoint latency**
35
+
36
+ ![Report overview: pass/fail summary, endpoint performance table with p50/p95 latency, and the filterable results table](https://raw.githubusercontent.com/sksingh329/pytest-api-core-framework/develop/docs/images/report-overview.png)
37
+
38
+ **Every assertion as its own row** — here inside `soft_assertions()`, so all three failures are reported in one run, as one error pointing at the test's own code
39
+
40
+ ![Expanded failed test showing a PATCH request banner, assertion rows with path, expected and actual values, and a single combined soft-assertion failure](https://raw.githubusercontent.com/sksingh329/pytest-api-core-framework/develop/docs/images/report-assertions.png)
41
+
42
+ **Request details, redacted secrets, Copy cURL, and timeouts shown as ERROR**
43
+
44
+ ![Expanded tests showing a token response with the access token redacted, and a request that timed out shown with a red ERROR banner](https://raw.githubusercontent.com/sksingh329/pytest-api-core-framework/develop/docs/images/report-requests.png)
45
+
46
+ ---
47
+
29
48
  ## Installation
30
49
 
31
50
  ```bash
32
- pip install pytest-api-core==1.1.0
51
+ pip install pytest-api-core==1.1.1
33
52
  ```
34
53
 
35
54
  With `.env` file support (recommended):
36
55
 
37
56
  ```bash
38
- pip install "pytest-api-core[dotenv]==1.1.0"
57
+ pip install "pytest-api-core[dotenv]==1.1.1"
39
58
  ```
40
59
 
41
60
  ---
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pytest-api-core"
7
- version = "1.1.0"
7
+ version = "1.1.1"
8
8
  description = "Pytest API automation framework with custom HTML reporting, reusable fixtures, and fluent assertions"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -24,7 +24,7 @@ from pytest_api_core.client.api_client import APIClient
24
24
  from pytest_api_core.client.api_response import APIResponse
25
25
  from pytest_api_core.security.redaction import add_sensitive_keys, register_secret
26
26
 
27
- __version__ = "1.1.0"
27
+ __version__ = "1.1.1"
28
28
  __all__ = [
29
29
  "APIClient",
30
30
  "APIResponse",
@@ -21,9 +21,8 @@ If the block raises some other exception, that exception propagates unchanged.
21
21
 
22
22
  from __future__ import annotations
23
23
 
24
- from contextlib import contextmanager
25
- from contextvars import ContextVar
26
- from typing import Iterator
24
+ from contextvars import ContextVar, Token
25
+ from types import TracebackType
27
26
 
28
27
  _collector: ContextVar[list[str] | None] = ContextVar("pytest_api_core_soft", default=None)
29
28
 
@@ -48,17 +47,33 @@ def _format(failures: list[str]) -> str:
48
47
  return "\n".join(lines)
49
48
 
50
49
 
51
- @contextmanager
52
- def soft_assertions() -> Iterator[None]:
53
- """Collect assertion failures in the block and raise one combined AssertionError."""
54
- if _collector.get() is not None:
55
- yield # nested: the outer block collects and raises
56
- return
57
- failures: list[str] = []
58
- token = _collector.set(failures)
59
- try:
60
- yield
61
- finally:
62
- _collector.reset(token)
63
- if failures:
64
- raise AssertionError(_format(failures))
50
+ class soft_assertions: # noqa: N801 — used like a function: ``with soft_assertions():``
51
+ """Collect assertion failures in the block and raise one combined AssertionError.
52
+
53
+ A class rather than ``@contextmanager`` so the raising frame can be hidden
54
+ from pytest tracebacks: the failure then points at the test's ``with`` line
55
+ instead of framework / ``contextlib`` internals.
56
+ """
57
+
58
+ def __init__(self) -> None:
59
+ self._failures: list[str] = []
60
+ self._token: Token[list[str] | None] | None = None
61
+
62
+ def __enter__(self) -> None:
63
+ if _collector.get() is None: # nested blocks report through the outermost one
64
+ self._failures = []
65
+ self._token = _collector.set(self._failures)
66
+
67
+ def __exit__(
68
+ self,
69
+ exc_type: type[BaseException] | None,
70
+ exc: BaseException | None,
71
+ tb: TracebackType | None,
72
+ ) -> None: # None: never swallows an exception raised inside the block
73
+ __tracebackhide__ = True # noqa: F841 — read by pytest
74
+ if self._token is None:
75
+ return
76
+ _collector.reset(self._token)
77
+ self._token = None
78
+ if exc_type is None and self._failures:
79
+ raise AssertionError(_format(self._failures))
@@ -199,7 +199,8 @@ footer { text-align: center; padding: 24px; color: var(--text-muted); font-size:
199
199
  </div>
200
200
  <div class="header-actions">
201
201
  <button class="theme-btn" onclick="toggleInfo()">⚙ Run Info</button>
202
- <button class="theme-btn" onclick="toggleTheme()">🌙 Dark</button>
202
+ {# Label names the theme the button switches *to*. #}
203
+ <button class="theme-btn" id="themeBtn" onclick="toggleTheme()">{% if theme == 'dark' %}☀️ Light{% else %}🌙 Dark{% endif %}</button>
203
204
  <div class="info-panel" id="infoPanel">
204
205
  <table class="info-table">
205
206
  {% for label, value in run_info %}
@@ -450,7 +451,7 @@ footer { text-align: center; padding: 24px; color: var(--text-muted); font-size:
450
451
  {% endif %}
451
452
  {% if a.expected is defined and a.actual is defined %}
452
453
  expected=<span class="exp">{{ a.expected }}</span>
453
- &nbsp; actual=<span class="got {% if not a.passed %}got{% endif %}">{{ a.actual }}</span>
454
+ &nbsp; actual=<span class="{% if a.passed %}exp{% else %}got{% endif %}">{{ a.actual }}</span>
454
455
  {% elif a.actual is defined %}
455
456
  actual=<span class="{% if a.passed %}exp{% else %}got{% endif %}">{{ a.actual }}</span>
456
457
  {% elif a.expected is defined %}
@@ -637,7 +638,7 @@ function toggleTheme() {
637
638
  var html = document.documentElement;
638
639
  var isDark = html.getAttribute('data-theme') === 'dark';
639
640
  html.setAttribute('data-theme', isDark ? 'light' : 'dark');
640
- document.querySelector('.theme-btn').textContent = isDark ? '🌙 Dark' : '☀️ Light';
641
+ document.getElementById('themeBtn').textContent = isDark ? '🌙 Dark' : '☀️ Light';
641
642
  }
642
643
  </script>
643
644
  </body>
@@ -46,6 +46,12 @@ _SENSITIVE_FRAGMENTS: tuple[str, ...] = (
46
46
  "privatekey",
47
47
  )
48
48
 
49
+ # Exact (normalised) keys that match a fragment above but never hold a secret.
50
+ # Kept deliberately tiny — a false "safe" leaks, a false "sensitive" only hides.
51
+ # token_type — OAuth 2.0 token response field, e.g. "Bearer" (RFC 6749 §5.1)
52
+ # add_sensitive_keys() still wins over this list.
53
+ _SAFE_KEYS: frozenset[str] = frozenset({"tokentype"})
54
+
49
55
  # Registered secrets shorter than this are ignored — masking "1" or "ab"
50
56
  # everywhere would mangle unrelated output.
51
57
  _MIN_SECRET_LEN = 4
@@ -91,7 +97,11 @@ def is_sensitive_key(key: object) -> bool:
91
97
  if not isinstance(key, str):
92
98
  return False
93
99
  norm = _normalise(key)
94
- return norm in _extra_keys or any(f in norm for f in _SENSITIVE_FRAGMENTS)
100
+ if norm in _extra_keys:
101
+ return True
102
+ if norm in _SAFE_KEYS:
103
+ return False
104
+ return any(f in norm for f in _SENSITIVE_FRAGMENTS)
95
105
 
96
106
 
97
107
  def is_sensitive_path(path: str | None) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-api-core
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: Pytest API automation framework with custom HTML reporting, reusable fixtures, and fluent assertions
5
5
  Author: QA Platform Team
6
6
  License: MIT License
@@ -92,16 +92,35 @@ Dynamic: license-file
92
92
 
93
93
  ---
94
94
 
95
+ ## Report preview
96
+
97
+ One self-contained HTML file per run (`--api-html-report=reports/report_{timestamp}.html`).
98
+ Browse real ones from this repo's CI on the [live reports dashboard](https://githubreports.apicore.subodhsingh.in/).
99
+
100
+ **Run summary and per-endpoint latency**
101
+
102
+ ![Report overview: pass/fail summary, endpoint performance table with p50/p95 latency, and the filterable results table](https://raw.githubusercontent.com/sksingh329/pytest-api-core-framework/develop/docs/images/report-overview.png)
103
+
104
+ **Every assertion as its own row** — here inside `soft_assertions()`, so all three failures are reported in one run, as one error pointing at the test's own code
105
+
106
+ ![Expanded failed test showing a PATCH request banner, assertion rows with path, expected and actual values, and a single combined soft-assertion failure](https://raw.githubusercontent.com/sksingh329/pytest-api-core-framework/develop/docs/images/report-assertions.png)
107
+
108
+ **Request details, redacted secrets, Copy cURL, and timeouts shown as ERROR**
109
+
110
+ ![Expanded tests showing a token response with the access token redacted, and a request that timed out shown with a red ERROR banner](https://raw.githubusercontent.com/sksingh329/pytest-api-core-framework/develop/docs/images/report-requests.png)
111
+
112
+ ---
113
+
95
114
  ## Installation
96
115
 
97
116
  ```bash
98
- pip install pytest-api-core==1.1.0
117
+ pip install pytest-api-core==1.1.1
99
118
  ```
100
119
 
101
120
  With `.env` file support (recommended):
102
121
 
103
122
  ```bash
104
- pip install "pytest-api-core[dotenv]==1.1.0"
123
+ pip install "pytest-api-core[dotenv]==1.1.1"
105
124
  ```
106
125
 
107
126
  ---
File without changes