kiwitcms-pytest-plugin 12.8.1__tar.gz → 15.4__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 (20) hide show
  1. {kiwitcms-pytest-plugin-12.8.1/kiwitcms_pytest_plugin.egg-info → kiwitcms_pytest_plugin-15.4}/PKG-INFO +22 -2
  2. {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-15.4}/README.rst +8 -0
  3. {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-15.4/kiwitcms_pytest_plugin.egg-info}/PKG-INFO +22 -2
  4. {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-15.4}/kiwitcms_pytest_plugin.egg-info/SOURCES.txt +3 -1
  5. kiwitcms_pytest_plugin-15.4/kiwitcms_pytest_plugin.egg-info/requires.txt +3 -0
  6. kiwitcms_pytest_plugin-15.4/requirements.txt +3 -0
  7. {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-15.4}/tcms_pytest_plugin/__init__.py +18 -0
  8. kiwitcms_pytest_plugin-15.4/tcms_pytest_plugin/version.py +1 -0
  9. kiwitcms_pytest_plugin-15.4/tests/test_docstring_reporting.py +139 -0
  10. kiwitcms_pytest_plugin-15.4/tests/test_kiwitcms.py +24 -0
  11. kiwitcms-pytest-plugin-12.8.1/kiwitcms_pytest_plugin.egg-info/requires.txt +0 -2
  12. kiwitcms-pytest-plugin-12.8.1/requirements.txt +0 -2
  13. kiwitcms-pytest-plugin-12.8.1/tcms_pytest_plugin/version.py +0 -1
  14. {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-15.4}/LICENSE +0 -0
  15. {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-15.4}/MANIFEST.in +0 -0
  16. {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-15.4}/kiwitcms_pytest_plugin.egg-info/dependency_links.txt +0 -0
  17. {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-15.4}/kiwitcms_pytest_plugin.egg-info/entry_points.txt +0 -0
  18. {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-15.4}/kiwitcms_pytest_plugin.egg-info/top_level.txt +0 -0
  19. {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-15.4}/setup.cfg +0 -0
  20. {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-15.4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: kiwitcms-pytest-plugin
3
- Version: 12.8.1
3
+ Version: 15.4
4
4
  Summary: Pytest plugin for Kiwi TCMS test case management system
5
5
  Home-page: https://github.com/kiwitcms/pytest-plugin
6
6
  Maintainer: Kiwi TCMS
@@ -25,6 +25,18 @@ Classifier: Topic :: Software Development :: Quality Assurance
25
25
  Classifier: Topic :: Software Development :: Testing
26
26
  Requires-Python: >=3.6
27
27
  License-File: LICENSE
28
+ Requires-Dist: pytest
29
+ Requires-Dist: tcms-api>=15.0
30
+ Requires-Dist: requests>=2.32.0
31
+ Dynamic: classifier
32
+ Dynamic: description
33
+ Dynamic: home-page
34
+ Dynamic: license-file
35
+ Dynamic: maintainer
36
+ Dynamic: maintainer-email
37
+ Dynamic: requires-dist
38
+ Dynamic: requires-python
39
+ Dynamic: summary
28
40
 
29
41
  ======================
30
42
  kiwitcms-pytest-plugin
@@ -90,6 +102,14 @@ Usage
90
102
  Changelog
91
103
  ---------
92
104
 
105
+ v15.4 (27 Apr 2026)
106
+ ~~~~~~~~~~~~~~~~~~~
107
+
108
+ - Publish test function docstring as TestCase.text (Carlos Martinez)
109
+ - Update tcms-api requirement from >=12.8.1 to >=15.0
110
+ - Drop Python 3.8 from test matrix
111
+
112
+
93
113
  v12.8.1 (22 Dec 2023)
94
114
  ~~~~~~~~~~~~~~~~~~~~~
95
115
 
@@ -62,6 +62,14 @@ Usage
62
62
  Changelog
63
63
  ---------
64
64
 
65
+ v15.4 (27 Apr 2026)
66
+ ~~~~~~~~~~~~~~~~~~~
67
+
68
+ - Publish test function docstring as TestCase.text (Carlos Martinez)
69
+ - Update tcms-api requirement from >=12.8.1 to >=15.0
70
+ - Drop Python 3.8 from test matrix
71
+
72
+
65
73
  v12.8.1 (22 Dec 2023)
66
74
  ~~~~~~~~~~~~~~~~~~~~~
67
75
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: kiwitcms-pytest-plugin
3
- Version: 12.8.1
3
+ Version: 15.4
4
4
  Summary: Pytest plugin for Kiwi TCMS test case management system
5
5
  Home-page: https://github.com/kiwitcms/pytest-plugin
6
6
  Maintainer: Kiwi TCMS
@@ -25,6 +25,18 @@ Classifier: Topic :: Software Development :: Quality Assurance
25
25
  Classifier: Topic :: Software Development :: Testing
26
26
  Requires-Python: >=3.6
27
27
  License-File: LICENSE
28
+ Requires-Dist: pytest
29
+ Requires-Dist: tcms-api>=15.0
30
+ Requires-Dist: requests>=2.32.0
31
+ Dynamic: classifier
32
+ Dynamic: description
33
+ Dynamic: home-page
34
+ Dynamic: license-file
35
+ Dynamic: maintainer
36
+ Dynamic: maintainer-email
37
+ Dynamic: requires-dist
38
+ Dynamic: requires-python
39
+ Dynamic: summary
28
40
 
29
41
  ======================
30
42
  kiwitcms-pytest-plugin
@@ -90,6 +102,14 @@ Usage
90
102
  Changelog
91
103
  ---------
92
104
 
105
+ v15.4 (27 Apr 2026)
106
+ ~~~~~~~~~~~~~~~~~~~
107
+
108
+ - Publish test function docstring as TestCase.text (Carlos Martinez)
109
+ - Update tcms-api requirement from >=12.8.1 to >=15.0
110
+ - Drop Python 3.8 from test matrix
111
+
112
+
93
113
  v12.8.1 (22 Dec 2023)
94
114
  ~~~~~~~~~~~~~~~~~~~~~
95
115
 
@@ -11,4 +11,6 @@ kiwitcms_pytest_plugin.egg-info/entry_points.txt
11
11
  kiwitcms_pytest_plugin.egg-info/requires.txt
12
12
  kiwitcms_pytest_plugin.egg-info/top_level.txt
13
13
  tcms_pytest_plugin/__init__.py
14
- tcms_pytest_plugin/version.py
14
+ tcms_pytest_plugin/version.py
15
+ tests/test_docstring_reporting.py
16
+ tests/test_kiwitcms.py
@@ -0,0 +1,3 @@
1
+ pytest
2
+ tcms-api>=15.0
3
+ requests>=2.32.0
@@ -0,0 +1,3 @@
1
+ pytest
2
+ tcms-api>=15.0
3
+ requests>=2.32.0 # not directly required, pinned by Snyk to avoid a vulnerability
@@ -8,6 +8,8 @@
8
8
  # pylint: disable=unused-argument, no-self-use
9
9
 
10
10
 
11
+ import inspect
12
+
11
13
  import pytest
12
14
  from tcms_api import plugin_helpers
13
15
 
@@ -35,6 +37,10 @@ class Backend(plugin_helpers.Backend):
35
37
  name = "kiwitcms-pytest-plugin"
36
38
  version = __version__
37
39
 
40
+ def update_test_case_text(self, test_case_id, text):
41
+ """Set the body text of a TestCase from its docstring."""
42
+ self.rpc.TestCase.update(test_case_id, {"text": text})
43
+
38
44
 
39
45
  class KiwiTCMSPlugin:
40
46
  executions = []
@@ -44,6 +50,15 @@ class KiwiTCMSPlugin:
44
50
 
45
51
  def __init__(self, verbose=False):
46
52
  self.backend = Backend(prefix="[pytest]", verbose=verbose)
53
+ self._docstrings = {}
54
+
55
+ def pytest_collection_finish(self, session):
56
+ for item in session.items:
57
+ if not hasattr(item, "function"):
58
+ continue
59
+ doc = getattr(item.function, "__doc__", None)
60
+ if doc:
61
+ self._docstrings[item.nodeid] = inspect.cleandoc(doc)
47
62
 
48
63
  def pytest_runtestloop(self, session):
49
64
  self.backend.configure()
@@ -53,6 +68,9 @@ class KiwiTCMSPlugin:
53
68
  self.comment = ""
54
69
 
55
70
  test_case, _ = self.backend.test_case_get_or_create(nodeid)
71
+ docstring = self._docstrings.get(nodeid)
72
+ if docstring != test_case["text"]:
73
+ self.backend.update_test_case_text(test_case["id"], docstring)
56
74
  self.backend.add_test_case_to_plan(test_case["id"], self.backend.plan_id)
57
75
  self.executions = self.backend.add_test_case_to_run(
58
76
  test_case["id"], self.backend.run_id
@@ -0,0 +1 @@
1
+ __version__ = "15.4"
@@ -0,0 +1,139 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) 2026 Carlos Martinez <jcmartinez2129@gmail.com>
3
+ # Licensed under the GPLv3: https://www.gnu.org/licenses/gpl.html
4
+ #
5
+ # pylint: disable=redefined-outer-name
6
+
7
+ from unittest.mock import MagicMock, patch
8
+
9
+ import pytest
10
+
11
+ from tcms_pytest_plugin import Backend, KiwiTCMSPlugin
12
+
13
+
14
+ @pytest.fixture
15
+ def plugin():
16
+ with patch("tcms_pytest_plugin.Backend") as mock_backend_cls:
17
+ instance = MagicMock()
18
+ instance.plan_id = 1
19
+ instance.run_id = 1
20
+ instance.test_case_get_or_create.return_value = ({"id": 99, "text": None}, True)
21
+ instance.add_test_case_to_run.return_value = [{"id": 42}]
22
+ mock_backend_cls.return_value = instance
23
+
24
+ p = KiwiTCMSPlugin()
25
+ p.backend = instance
26
+ yield p
27
+
28
+
29
+ def _make_item(nodeid, docstring):
30
+ """Create a minimal mock pytest item with a function docstring."""
31
+ item = MagicMock()
32
+ item.nodeid = nodeid
33
+ item.function.__doc__ = docstring
34
+ return item
35
+
36
+
37
+ def _simulate_collection(plugin, items):
38
+ session = MagicMock()
39
+ session.items = items
40
+ plugin.pytest_collection_finish(session)
41
+
42
+
43
+ def _simulate_logstart(plugin, nodeid):
44
+ plugin.pytest_runtest_logstart(nodeid=nodeid, location=("", 0, ""))
45
+
46
+
47
+ def test_docstring_is_sent_as_test_case_text(plugin):
48
+ """Test case body must be set from the function docstring when present."""
49
+ items = [
50
+ _make_item(
51
+ "tests/test_foo.py::test_intent", "Verify the widget resets on power-up."
52
+ )
53
+ ]
54
+ _simulate_collection(plugin, items)
55
+ _simulate_logstart(plugin, "tests/test_foo.py::test_intent")
56
+
57
+ plugin.backend.update_test_case_text.assert_called_once_with(
58
+ 99, "Verify the widget resets on power-up."
59
+ )
60
+
61
+
62
+ def test_no_update_when_docstring_is_absent(plugin):
63
+ """update_test_case_text must not be called when the test has no docstring."""
64
+ item = MagicMock()
65
+ item.nodeid = "tests/test_foo.py::test_no_doc"
66
+ item.function.__doc__ = None
67
+ _simulate_collection(plugin, [item])
68
+ _simulate_logstart(plugin, "tests/test_foo.py::test_no_doc")
69
+
70
+ plugin.backend.update_test_case_text.assert_not_called()
71
+
72
+
73
+ def test_no_update_when_docstring_is_empty_string(plugin):
74
+ """update_test_case_text must not be called when the docstring is an empty string."""
75
+ items = [_make_item("tests/test_foo.py::test_empty_doc", "")]
76
+ _simulate_collection(plugin, items)
77
+ _simulate_logstart(plugin, "tests/test_foo.py::test_empty_doc")
78
+
79
+ plugin.backend.update_test_case_text.assert_not_called()
80
+
81
+
82
+ def test_multiline_docstring_is_cleandoc_normalised(plugin):
83
+ """inspect.cleandoc must be used so internal indentation is normalised."""
84
+ raw_doc = (
85
+ "\n Verify the widget resets on power-up."
86
+ "\n\n Precondition: widget is powered.\n "
87
+ )
88
+ items = [_make_item("tests/test_foo.py::test_multiline", raw_doc)]
89
+ _simulate_collection(plugin, items)
90
+ _simulate_logstart(plugin, "tests/test_foo.py::test_multiline")
91
+
92
+ expected = (
93
+ "Verify the widget resets on power-up.\n\nPrecondition: widget is powered."
94
+ )
95
+ plugin.backend.update_test_case_text.assert_called_once_with(99, expected)
96
+
97
+
98
+ def test_item_without_function_attribute_is_skipped(plugin):
99
+ """Items without a .function attribute (e.g. doctest items) must not crash collection."""
100
+ item = MagicMock(spec=[]) # no attributes at all
101
+ item.nodeid = "tests/test_foo.py::test_synthetic"
102
+ session = MagicMock()
103
+ session.items = [item]
104
+
105
+ plugin.pytest_collection_finish(session) # must not raise
106
+
107
+ plugin.backend.update_test_case_text.assert_not_called()
108
+
109
+
110
+ def test_docstring_not_sent_for_different_nodeid(plugin):
111
+ """Docstring for test_a must be sent when test_a runs, but not when test_b runs."""
112
+ item_a = _make_item("tests/test_foo.py::test_a", "Intention A")
113
+ item_b = _make_item("tests/test_foo.py::test_b", None)
114
+ _simulate_collection(plugin, [item_a, item_b])
115
+
116
+ _simulate_logstart(plugin, "tests/test_foo.py::test_a")
117
+ plugin.backend.test_case_get_or_create.assert_called_once_with(
118
+ "tests/test_foo.py::test_a"
119
+ )
120
+ plugin.backend.update_test_case_text.assert_called_once_with(99, "Intention A")
121
+
122
+ plugin.backend.test_case_get_or_create.reset_mock()
123
+ plugin.backend.update_test_case_text.reset_mock()
124
+
125
+ _simulate_logstart(plugin, "tests/test_foo.py::test_b")
126
+ plugin.backend.test_case_get_or_create.assert_called_once_with(
127
+ "tests/test_foo.py::test_b"
128
+ )
129
+ plugin.backend.update_test_case_text.assert_not_called()
130
+
131
+
132
+ def test_backend_update_test_case_text_calls_rpc():
133
+ """Backend.update_test_case_text must call TestCase.update with the text field."""
134
+ backend = Backend.__new__(Backend)
135
+ backend.rpc = MagicMock()
136
+
137
+ backend.update_test_case_text(test_case_id=7, text="Some intention.")
138
+
139
+ backend.rpc.TestCase.update.assert_called_once_with(7, {"text": "Some intention."})
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) 2019 Dmitry Dygalo <dadygalo@gmail.com>
3
+ # Copyright (c) 2022 Alexander Todorov <atodorov@otb.bg>
4
+ # Licensed under the GPLv3: https://www.gnu.org/licenses/gpl.html
5
+ #
6
+ # pylint: disable=comparison-of-constants, unused-argument
7
+ import pytest
8
+
9
+
10
+ def test_should_pass_when_assertion_passes():
11
+ assert True
12
+
13
+
14
+ def test_should_fail_when_assertion_fails():
15
+ assert 1 == 2
16
+
17
+
18
+ @pytest.mark.skip("We've decided not to test this")
19
+ def test_should_skip_if_marked_as_such():
20
+ assert True
21
+
22
+
23
+ def test_should_error_with_non_existing_fixture(non_existing):
24
+ assert 1 == ""
@@ -1,2 +0,0 @@
1
- pytest
2
- tcms-api>=12.8.1
@@ -1,2 +0,0 @@
1
- pytest
2
- tcms-api>=12.8.1
@@ -1 +0,0 @@
1
- __version__ = "12.8.1"