pytest-requirements 0.0.0.dev0__py3-none-any.whl

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.
@@ -0,0 +1,31 @@
1
+ """pytest plugin providing markers to link tests to requirements and usecases."""
2
+
3
+ from ._version import __version__
4
+
5
+
6
+ def pytest_configure(config):
7
+ """Register our custom markers."""
8
+ config.addinivalue_line(
9
+ "markers",
10
+ "verifies_requirement(requirement_id): Mark this test as verification for a requirement",
11
+ )
12
+ config.addinivalue_line(
13
+ "markers",
14
+ "verifies_usecase(usecase_id): Mark this test as verification for a usecase",
15
+ )
16
+
17
+
18
+ def pytest_collection_modifyitems(session, config, items):
19
+ """Customize test collection.
20
+
21
+ - Make sure requirement/usecase marker information is written to junit xml.
22
+ """
23
+ for item in items:
24
+ for type_ in ("requirement", "usecase"):
25
+ for marker in item.iter_markers(name=f"verifies_{type_}"):
26
+ item.user_properties.append((f"{type_}_id", marker.args[0]))
27
+
28
+
29
+ __all__ = [
30
+ "__version__",
31
+ ]
@@ -0,0 +1,16 @@
1
+ # file generated by setuptools_scm
2
+ # don't change, don't track in version control
3
+ TYPE_CHECKING = False
4
+ if TYPE_CHECKING:
5
+ from typing import Tuple, Union
6
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
7
+ else:
8
+ VERSION_TUPLE = object
9
+
10
+ version: str
11
+ __version__: str
12
+ __version_tuple__: VERSION_TUPLE
13
+ version_tuple: VERSION_TUPLE
14
+
15
+ __version__ = version = '0.0.0.dev0'
16
+ __version_tuple__ = version_tuple = (0, 0, 0, 'dev0')
@@ -0,0 +1,65 @@
1
+ from xml.etree import ElementTree as ET
2
+
3
+ EXPECTED = {
4
+ "test_single_requirement": {
5
+ "requirements": ["B-DPPS-0123"],
6
+ "usecases": [],
7
+ },
8
+ "test_multiple_requirements": {
9
+ "requirements": ["B-DPPS-0123", "B-DPPS-0124", "B-DPPS-0125"],
10
+ "usecases": [],
11
+ },
12
+ "test_usecase": {
13
+ "requirements": [],
14
+ "usecases": ["UC-130-1.2"],
15
+ },
16
+ "test_multiple_usecases": {
17
+ "requirements": [],
18
+ "usecases": ["UC-130-1.2.1", "UC-130-1.2.2"],
19
+ },
20
+ "test_mixed": {
21
+ "requirements": ["B-DPPS-0123"],
22
+ "usecases": ["UC-130-1.2.1", "UC-130-1.2.2"],
23
+ },
24
+ }
25
+
26
+
27
+ def collect_markers(test_case):
28
+ markers = {"requirements": [], "usecases": []}
29
+ for prop in test_case.iter("property"):
30
+ if prop.attrib["name"] == "requirement_id":
31
+ markers["requirements"].append(prop.attrib["value"])
32
+ elif prop.attrib["name"] == "usecase_id":
33
+ markers["usecases"].append(prop.attrib["value"])
34
+ return markers
35
+
36
+
37
+ def test_plugin(pytester, tmp_path):
38
+ pytester.copy_example("conftest.py")
39
+ pytester.copy_example("test_requirements.py")
40
+
41
+ report_path = tmp_path / "report.xml"
42
+ result = pytester.runpytest(f"--junit-xml={report_path}")
43
+
44
+ result.assert_outcomes(passed=5)
45
+
46
+ # make sure the marker information is in the junit xml
47
+ tree = ET.parse(report_path)
48
+
49
+ test_cases = {
50
+ test_case.attrib["name"]: test_case for test_case in tree.iter("testcase")
51
+ }
52
+ assert len(test_cases) == 5
53
+
54
+ for key, expected in EXPECTED.items():
55
+ markers = collect_markers(test_cases[key])
56
+ for type_, expected_ids in expected.items():
57
+ ids = markers[type_]
58
+ assert len(ids) == len(expected_ids)
59
+ assert set(ids) == set(expected_ids)
60
+
61
+
62
+ def test_version():
63
+ from pytest_requirements import __version__
64
+
65
+ assert __version__ != "0.0.0"
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024, Cherenkov Telescope Array Observatory
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.1
2
+ Name: pytest-requirements
3
+ Version: 0.0.0.dev0
4
+ Summary: pytest plugin for using custom markers to relate tests to requirements and usecases
5
+ Author-email: Maximilian Linhoff <maximilian.linhoff@tu-dortmund.de>
6
+ License: BSD-3-Clause
7
+ Project-URL: repository, https://gitlab.cta-observatory.org/cta-computing/common/pytest-requirements
8
+ Project-URL: documentation, http://cta-computing.gitlab-pages.cta-observatory.org/common/pytest-requirements
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: pytest
13
+ Provides-Extra: test
14
+ Requires-Dist: pytest-cov; extra == "test"
15
+ Provides-Extra: doc
16
+ Requires-Dist: sphinx; extra == "doc"
17
+ Requires-Dist: numpydoc; extra == "doc"
18
+ Requires-Dist: ctao-sphinx-theme~=0.1.2; extra == "doc"
19
+ Requires-Dist: sphinx-changelog; extra == "doc"
20
+ Provides-Extra: dev
21
+ Requires-Dist: setuptools_scm; extra == "dev"
22
+ Requires-Dist: towncrier; extra == "dev"
23
+ Provides-Extra: all
24
+ Requires-Dist: pytest-requirements[dev,doc,test]; extra == "all"
25
+
26
+ # pytest-requirements
27
+
28
+
29
+ pytest plugin providing markers to link tests to requirements and usecases.
@@ -0,0 +1,9 @@
1
+ pytest_requirements/__init__.py,sha256=XZeJ_9nUUhgmNMcqRzUP3Z11s_i1goUS6JBjwM20pd8,919
2
+ pytest_requirements/_version.py,sha256=qharzApsLGL2RoMhav5KFtnE6oeBEGFs89k6qEvDTIw,424
3
+ pytest_requirements/test_plugin.py,sha256=nJP6Ldwg_VNp1A5LzFO9Tm3k_VFsHR_r27OwC_I5EjQ,1902
4
+ pytest_requirements-0.0.0.dev0.dist-info/LICENSE,sha256=HuMcEyFbhXPlPf_O6TOBJ_8hKr6W8TYvHT3_fjD_I8I,1545
5
+ pytest_requirements-0.0.0.dev0.dist-info/METADATA,sha256=R9HfjnCgroEvtSVMGIHuLmaNmdSftve6PILfMxdsVKs,1128
6
+ pytest_requirements-0.0.0.dev0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
7
+ pytest_requirements-0.0.0.dev0.dist-info/entry_points.txt,sha256=AhCBkNfLFg5eLzf22fHGtELkERhn2UftIDJK3zcMf2Q,53
8
+ pytest_requirements-0.0.0.dev0.dist-info/top_level.txt,sha256=u-AZz9GFmd0-7TSON3fmUWvttA1V84wsE8bFWLwZ0iE,20
9
+ pytest_requirements-0.0.0.dev0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.6.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [pytest11]
2
+ pytest_requirements = pytest_requirements
@@ -0,0 +1 @@
1
+ pytest_requirements