kiwitcms-pytest-plugin 12.8.1__tar.gz → 17.3__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.
- {kiwitcms-pytest-plugin-12.8.1/kiwitcms_pytest_plugin.egg-info → kiwitcms_pytest_plugin-17.3}/PKG-INFO +48 -15
- {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-17.3}/README.rst +32 -8
- {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-17.3/kiwitcms_pytest_plugin.egg-info}/PKG-INFO +48 -15
- {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-17.3}/kiwitcms_pytest_plugin.egg-info/SOURCES.txt +3 -1
- kiwitcms_pytest_plugin-17.3/kiwitcms_pytest_plugin.egg-info/requires.txt +3 -0
- kiwitcms_pytest_plugin-17.3/requirements.txt +3 -0
- {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-17.3}/setup.cfg +4 -0
- {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-17.3}/setup.py +2 -6
- {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-17.3}/tcms_pytest_plugin/__init__.py +22 -1
- kiwitcms_pytest_plugin-17.3/tcms_pytest_plugin/version.py +1 -0
- kiwitcms_pytest_plugin-17.3/tests/test_docstring_reporting.py +202 -0
- kiwitcms_pytest_plugin-17.3/tests/test_kiwitcms.py +24 -0
- kiwitcms-pytest-plugin-12.8.1/kiwitcms_pytest_plugin.egg-info/requires.txt +0 -2
- kiwitcms-pytest-plugin-12.8.1/requirements.txt +0 -2
- kiwitcms-pytest-plugin-12.8.1/tcms_pytest_plugin/version.py +0 -1
- {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-17.3}/LICENSE +0 -0
- {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-17.3}/MANIFEST.in +0 -0
- {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-17.3}/kiwitcms_pytest_plugin.egg-info/dependency_links.txt +0 -0
- {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-17.3}/kiwitcms_pytest_plugin.egg-info/entry_points.txt +0 -0
- {kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-17.3}/kiwitcms_pytest_plugin.egg-info/top_level.txt +0 -0
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: kiwitcms-pytest-plugin
|
|
3
|
-
Version:
|
|
3
|
+
Version: 17.3
|
|
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
|
|
7
7
|
Maintainer-email: info@kiwitcms.org
|
|
8
|
+
License: GPLv3
|
|
8
9
|
Classifier: Development Status :: 4 - Beta
|
|
9
10
|
Classifier: Environment :: Console
|
|
10
11
|
Classifier: Framework :: Pytest
|
|
11
12
|
Classifier: Intended Audience :: Developers
|
|
12
13
|
Classifier: Intended Audience :: System Administrators
|
|
13
|
-
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
14
14
|
Classifier: Operating System :: POSIX
|
|
15
15
|
Classifier: Programming Language :: Python
|
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
18
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
22
19
|
Classifier: Topic :: Software Development
|
|
23
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
@@ -25,6 +22,18 @@ Classifier: Topic :: Software Development :: Quality Assurance
|
|
|
25
22
|
Classifier: Topic :: Software Development :: Testing
|
|
26
23
|
Requires-Python: >=3.6
|
|
27
24
|
License-File: LICENSE
|
|
25
|
+
Requires-Dist: pytest
|
|
26
|
+
Requires-Dist: tcms-api>=17.3
|
|
27
|
+
Requires-Dist: requests>=2.34.2
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description
|
|
30
|
+
Dynamic: home-page
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
Dynamic: maintainer
|
|
33
|
+
Dynamic: maintainer-email
|
|
34
|
+
Dynamic: requires-dist
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
Dynamic: summary
|
|
28
37
|
|
|
29
38
|
======================
|
|
30
39
|
kiwitcms-pytest-plugin
|
|
@@ -38,14 +47,6 @@ kiwitcms-pytest-plugin
|
|
|
38
47
|
:target: https://pypi.org/project/kiwitcms-pytest-plugin
|
|
39
48
|
:alt: Python versions
|
|
40
49
|
|
|
41
|
-
.. image:: https://tidelift.com/badges/package/pypi/kiwitcms
|
|
42
|
-
:target: https://tidelift.com/subscription/pkg/pypi-kiwitcms?utm_source=pypi-kiwitcms&utm_medium=github&utm_campaign=readme
|
|
43
|
-
:alt: Tidelift
|
|
44
|
-
|
|
45
|
-
.. image:: https://opencollective.com/kiwitcms/tiers/sponsor/badge.svg?label=sponsors&color=brightgreen
|
|
46
|
-
:target: https://opencollective.com/kiwitcms#contributors
|
|
47
|
-
:alt: Become a sponsor
|
|
48
|
-
|
|
49
50
|
.. image:: https://img.shields.io/twitter/follow/KiwiTCMS.svg
|
|
50
51
|
:target: https://twitter.com/KiwiTCMS
|
|
51
52
|
:alt: Kiwi TCMS on Twitter
|
|
@@ -87,9 +88,41 @@ Usage
|
|
|
87
88
|
pytest -p tcms_pytest_plugin --kiwitcms
|
|
88
89
|
|
|
89
90
|
|
|
91
|
+
Stable test case identification
|
|
92
|
+
-------------------------------
|
|
93
|
+
|
|
94
|
+
Test functions can be decorated with ``@TestCase`` from
|
|
95
|
+
``tcms_api.plugin_helpers`` to reuse an existing TestCase or to specify
|
|
96
|
+
additional TestCase fields::
|
|
97
|
+
|
|
98
|
+
from tcms_api.plugin_helpers import TestCase
|
|
99
|
+
|
|
100
|
+
@TestCase(id=45)
|
|
101
|
+
def test_coupon_guest():
|
|
102
|
+
...
|
|
103
|
+
|
|
104
|
+
|
|
90
105
|
Changelog
|
|
91
106
|
---------
|
|
92
107
|
|
|
108
|
+
v17.3 (04 Dec 2026)
|
|
109
|
+
~~~~~~~~~~~~~~~~~~~
|
|
110
|
+
|
|
111
|
+
- Update tcms-api from 15.0 to 17.3
|
|
112
|
+
- Support the ``@tcms_api.plugin_helpers.TestCase`` decorator for stable
|
|
113
|
+
test case identification
|
|
114
|
+
- Update TestCase.text from the docstring only when the database value is
|
|
115
|
+
empty
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
v15.4 (27 Apr 2026)
|
|
119
|
+
~~~~~~~~~~~~~~~~~~~
|
|
120
|
+
|
|
121
|
+
- Publish test function docstring as TestCase.text (Carlos Martinez)
|
|
122
|
+
- Update tcms-api requirement from >=12.8.1 to >=15.0
|
|
123
|
+
- Drop Python 3.8 from test matrix
|
|
124
|
+
|
|
125
|
+
|
|
93
126
|
v12.8.1 (22 Dec 2023)
|
|
94
127
|
~~~~~~~~~~~~~~~~~~~~~
|
|
95
128
|
|
|
@@ -10,14 +10,6 @@ kiwitcms-pytest-plugin
|
|
|
10
10
|
:target: https://pypi.org/project/kiwitcms-pytest-plugin
|
|
11
11
|
:alt: Python versions
|
|
12
12
|
|
|
13
|
-
.. image:: https://tidelift.com/badges/package/pypi/kiwitcms
|
|
14
|
-
:target: https://tidelift.com/subscription/pkg/pypi-kiwitcms?utm_source=pypi-kiwitcms&utm_medium=github&utm_campaign=readme
|
|
15
|
-
:alt: Tidelift
|
|
16
|
-
|
|
17
|
-
.. image:: https://opencollective.com/kiwitcms/tiers/sponsor/badge.svg?label=sponsors&color=brightgreen
|
|
18
|
-
:target: https://opencollective.com/kiwitcms#contributors
|
|
19
|
-
:alt: Become a sponsor
|
|
20
|
-
|
|
21
13
|
.. image:: https://img.shields.io/twitter/follow/KiwiTCMS.svg
|
|
22
14
|
:target: https://twitter.com/KiwiTCMS
|
|
23
15
|
:alt: Kiwi TCMS on Twitter
|
|
@@ -59,9 +51,41 @@ Usage
|
|
|
59
51
|
pytest -p tcms_pytest_plugin --kiwitcms
|
|
60
52
|
|
|
61
53
|
|
|
54
|
+
Stable test case identification
|
|
55
|
+
-------------------------------
|
|
56
|
+
|
|
57
|
+
Test functions can be decorated with ``@TestCase`` from
|
|
58
|
+
``tcms_api.plugin_helpers`` to reuse an existing TestCase or to specify
|
|
59
|
+
additional TestCase fields::
|
|
60
|
+
|
|
61
|
+
from tcms_api.plugin_helpers import TestCase
|
|
62
|
+
|
|
63
|
+
@TestCase(id=45)
|
|
64
|
+
def test_coupon_guest():
|
|
65
|
+
...
|
|
66
|
+
|
|
67
|
+
|
|
62
68
|
Changelog
|
|
63
69
|
---------
|
|
64
70
|
|
|
71
|
+
v17.3 (04 Dec 2026)
|
|
72
|
+
~~~~~~~~~~~~~~~~~~~
|
|
73
|
+
|
|
74
|
+
- Update tcms-api from 15.0 to 17.3
|
|
75
|
+
- Support the ``@tcms_api.plugin_helpers.TestCase`` decorator for stable
|
|
76
|
+
test case identification
|
|
77
|
+
- Update TestCase.text from the docstring only when the database value is
|
|
78
|
+
empty
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
v15.4 (27 Apr 2026)
|
|
82
|
+
~~~~~~~~~~~~~~~~~~~
|
|
83
|
+
|
|
84
|
+
- Publish test function docstring as TestCase.text (Carlos Martinez)
|
|
85
|
+
- Update tcms-api requirement from >=12.8.1 to >=15.0
|
|
86
|
+
- Drop Python 3.8 from test matrix
|
|
87
|
+
|
|
88
|
+
|
|
65
89
|
v12.8.1 (22 Dec 2023)
|
|
66
90
|
~~~~~~~~~~~~~~~~~~~~~
|
|
67
91
|
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: kiwitcms-pytest-plugin
|
|
3
|
-
Version:
|
|
3
|
+
Version: 17.3
|
|
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
|
|
7
7
|
Maintainer-email: info@kiwitcms.org
|
|
8
|
+
License: GPLv3
|
|
8
9
|
Classifier: Development Status :: 4 - Beta
|
|
9
10
|
Classifier: Environment :: Console
|
|
10
11
|
Classifier: Framework :: Pytest
|
|
11
12
|
Classifier: Intended Audience :: Developers
|
|
12
13
|
Classifier: Intended Audience :: System Administrators
|
|
13
|
-
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
14
14
|
Classifier: Operating System :: POSIX
|
|
15
15
|
Classifier: Programming Language :: Python
|
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
18
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
22
19
|
Classifier: Topic :: Software Development
|
|
23
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
@@ -25,6 +22,18 @@ Classifier: Topic :: Software Development :: Quality Assurance
|
|
|
25
22
|
Classifier: Topic :: Software Development :: Testing
|
|
26
23
|
Requires-Python: >=3.6
|
|
27
24
|
License-File: LICENSE
|
|
25
|
+
Requires-Dist: pytest
|
|
26
|
+
Requires-Dist: tcms-api>=17.3
|
|
27
|
+
Requires-Dist: requests>=2.34.2
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description
|
|
30
|
+
Dynamic: home-page
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
Dynamic: maintainer
|
|
33
|
+
Dynamic: maintainer-email
|
|
34
|
+
Dynamic: requires-dist
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
Dynamic: summary
|
|
28
37
|
|
|
29
38
|
======================
|
|
30
39
|
kiwitcms-pytest-plugin
|
|
@@ -38,14 +47,6 @@ kiwitcms-pytest-plugin
|
|
|
38
47
|
:target: https://pypi.org/project/kiwitcms-pytest-plugin
|
|
39
48
|
:alt: Python versions
|
|
40
49
|
|
|
41
|
-
.. image:: https://tidelift.com/badges/package/pypi/kiwitcms
|
|
42
|
-
:target: https://tidelift.com/subscription/pkg/pypi-kiwitcms?utm_source=pypi-kiwitcms&utm_medium=github&utm_campaign=readme
|
|
43
|
-
:alt: Tidelift
|
|
44
|
-
|
|
45
|
-
.. image:: https://opencollective.com/kiwitcms/tiers/sponsor/badge.svg?label=sponsors&color=brightgreen
|
|
46
|
-
:target: https://opencollective.com/kiwitcms#contributors
|
|
47
|
-
:alt: Become a sponsor
|
|
48
|
-
|
|
49
50
|
.. image:: https://img.shields.io/twitter/follow/KiwiTCMS.svg
|
|
50
51
|
:target: https://twitter.com/KiwiTCMS
|
|
51
52
|
:alt: Kiwi TCMS on Twitter
|
|
@@ -87,9 +88,41 @@ Usage
|
|
|
87
88
|
pytest -p tcms_pytest_plugin --kiwitcms
|
|
88
89
|
|
|
89
90
|
|
|
91
|
+
Stable test case identification
|
|
92
|
+
-------------------------------
|
|
93
|
+
|
|
94
|
+
Test functions can be decorated with ``@TestCase`` from
|
|
95
|
+
``tcms_api.plugin_helpers`` to reuse an existing TestCase or to specify
|
|
96
|
+
additional TestCase fields::
|
|
97
|
+
|
|
98
|
+
from tcms_api.plugin_helpers import TestCase
|
|
99
|
+
|
|
100
|
+
@TestCase(id=45)
|
|
101
|
+
def test_coupon_guest():
|
|
102
|
+
...
|
|
103
|
+
|
|
104
|
+
|
|
90
105
|
Changelog
|
|
91
106
|
---------
|
|
92
107
|
|
|
108
|
+
v17.3 (04 Dec 2026)
|
|
109
|
+
~~~~~~~~~~~~~~~~~~~
|
|
110
|
+
|
|
111
|
+
- Update tcms-api from 15.0 to 17.3
|
|
112
|
+
- Support the ``@tcms_api.plugin_helpers.TestCase`` decorator for stable
|
|
113
|
+
test case identification
|
|
114
|
+
- Update TestCase.text from the docstring only when the database value is
|
|
115
|
+
empty
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
v15.4 (27 Apr 2026)
|
|
119
|
+
~~~~~~~~~~~~~~~~~~~
|
|
120
|
+
|
|
121
|
+
- Publish test function docstring as TestCase.text (Carlos Martinez)
|
|
122
|
+
- Update tcms-api requirement from >=12.8.1 to >=15.0
|
|
123
|
+
- Drop Python 3.8 from test matrix
|
|
124
|
+
|
|
125
|
+
|
|
93
126
|
v12.8.1 (22 Dec 2023)
|
|
94
127
|
~~~~~~~~~~~~~~~~~~~~~
|
|
95
128
|
|
|
@@ -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
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Copyright (c) 2019 Dmitry Dygalo <dadygalo@gmail.com>
|
|
5
5
|
# Copyright (c) 2021 Bryan Mutai <mutaiwork@gmail.com>
|
|
6
|
-
# Copyright (c) 2021-
|
|
6
|
+
# Copyright (c) 2021-2026 Alexander Todorov <atodorov@otb.bg>
|
|
7
7
|
#
|
|
8
8
|
# Licensed under the GPLv3: https://www.gnu.org/licenses/gpl.html
|
|
9
9
|
import os
|
|
@@ -46,14 +46,10 @@ setup(
|
|
|
46
46
|
"Framework :: Pytest",
|
|
47
47
|
"Intended Audience :: Developers",
|
|
48
48
|
"Intended Audience :: System Administrators",
|
|
49
|
-
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
50
49
|
"Operating System :: POSIX",
|
|
51
50
|
"Programming Language :: Python",
|
|
52
51
|
"Programming Language :: Python :: 3",
|
|
53
|
-
"Programming Language :: Python :: 3.
|
|
54
|
-
"Programming Language :: Python :: 3.7",
|
|
55
|
-
"Programming Language :: Python :: 3.8",
|
|
56
|
-
"Programming Language :: Python :: 3.11",
|
|
52
|
+
"Programming Language :: Python :: 3.14",
|
|
57
53
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
58
54
|
"Topic :: Software Development",
|
|
59
55
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
{kiwitcms-pytest-plugin-12.8.1 → kiwitcms_pytest_plugin-17.3}/tcms_pytest_plugin/__init__.py
RENAMED
|
@@ -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,17 @@ class KiwiTCMSPlugin:
|
|
|
44
50
|
|
|
45
51
|
def __init__(self, verbose=False):
|
|
46
52
|
self.backend = Backend(prefix="[pytest]", verbose=verbose)
|
|
53
|
+
self._docstrings = {}
|
|
54
|
+
self._test_functions = {}
|
|
55
|
+
|
|
56
|
+
def pytest_collection_finish(self, session):
|
|
57
|
+
for item in session.items:
|
|
58
|
+
if not hasattr(item, "function"):
|
|
59
|
+
continue
|
|
60
|
+
self._test_functions[item.nodeid] = item.function
|
|
61
|
+
doc = getattr(item.function, "__doc__", None)
|
|
62
|
+
if doc:
|
|
63
|
+
self._docstrings[item.nodeid] = inspect.cleandoc(doc)
|
|
47
64
|
|
|
48
65
|
def pytest_runtestloop(self, session):
|
|
49
66
|
self.backend.configure()
|
|
@@ -52,7 +69,11 @@ class KiwiTCMSPlugin:
|
|
|
52
69
|
self.status_weight = 0
|
|
53
70
|
self.comment = ""
|
|
54
71
|
|
|
55
|
-
|
|
72
|
+
test_func = self._test_functions.get(nodeid)
|
|
73
|
+
test_case, _ = self.backend.test_case_get_or_create(nodeid, test_func)
|
|
74
|
+
docstring = self._docstrings.get(nodeid)
|
|
75
|
+
if docstring and not test_case["text"]:
|
|
76
|
+
self.backend.update_test_case_text(test_case["id"], docstring)
|
|
56
77
|
self.backend.add_test_case_to_plan(test_case["id"], self.backend.plan_id)
|
|
57
78
|
self.executions = self.backend.add_test_case_to_run(
|
|
58
79
|
test_case["id"], self.backend.run_id
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "17.3"
|
|
@@ -0,0 +1,202 @@
|
|
|
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_api import plugin_helpers
|
|
12
|
+
from tcms_pytest_plugin import Backend, KiwiTCMSPlugin
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@pytest.fixture
|
|
16
|
+
def plugin():
|
|
17
|
+
with patch("tcms_pytest_plugin.Backend") as mock_backend_cls:
|
|
18
|
+
instance = MagicMock()
|
|
19
|
+
instance.plan_id = 1
|
|
20
|
+
instance.run_id = 1
|
|
21
|
+
instance.test_case_get_or_create.return_value = ({"id": 99, "text": None}, True)
|
|
22
|
+
instance.add_test_case_to_run.return_value = [{"id": 42}]
|
|
23
|
+
mock_backend_cls.return_value = instance
|
|
24
|
+
|
|
25
|
+
p = KiwiTCMSPlugin()
|
|
26
|
+
p.backend = instance
|
|
27
|
+
yield p
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _make_item(nodeid, docstring, decorator_fields=None):
|
|
31
|
+
"""Create a minimal mock pytest item with a function docstring."""
|
|
32
|
+
item = MagicMock()
|
|
33
|
+
item.nodeid = nodeid
|
|
34
|
+
item.function.__doc__ = docstring
|
|
35
|
+
if decorator_fields:
|
|
36
|
+
plugin_helpers.TestCase(**decorator_fields)(item.function)
|
|
37
|
+
return item
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _simulate_collection(plugin, items):
|
|
41
|
+
session = MagicMock()
|
|
42
|
+
session.items = items
|
|
43
|
+
plugin.pytest_collection_finish(session)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _simulate_logstart(plugin, nodeid):
|
|
47
|
+
plugin.pytest_runtest_logstart(nodeid=nodeid, location=("", 0, ""))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_docstring_is_sent_as_test_case_text(plugin):
|
|
51
|
+
"""Test case body must be set from the function docstring when present."""
|
|
52
|
+
items = [
|
|
53
|
+
_make_item(
|
|
54
|
+
"tests/test_foo.py::test_intent", "Verify the widget resets on power-up."
|
|
55
|
+
)
|
|
56
|
+
]
|
|
57
|
+
_simulate_collection(plugin, items)
|
|
58
|
+
_simulate_logstart(plugin, "tests/test_foo.py::test_intent")
|
|
59
|
+
|
|
60
|
+
plugin.backend.update_test_case_text.assert_called_once_with(
|
|
61
|
+
99, "Verify the widget resets on power-up."
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_decorated_function_is_passed_to_backend(plugin):
|
|
66
|
+
"""The function object must be passed so @TestCase fields are used."""
|
|
67
|
+
item = _make_item("tests/test_foo.py::test_decorated", "Intent")
|
|
68
|
+
_simulate_collection(plugin, [item])
|
|
69
|
+
_simulate_logstart(plugin, "tests/test_foo.py::test_decorated")
|
|
70
|
+
|
|
71
|
+
plugin.backend.test_case_get_or_create.assert_called_once_with(
|
|
72
|
+
"tests/test_foo.py::test_decorated", item.function
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_decorator_text_is_not_overwritten_by_docstring(plugin):
|
|
77
|
+
"""An explicit @TestCase(text=...) must win over the docstring."""
|
|
78
|
+
plugin.backend.test_case_get_or_create.return_value = (
|
|
79
|
+
{"id": 99, "text": "Explicit text"},
|
|
80
|
+
True,
|
|
81
|
+
)
|
|
82
|
+
item = _make_item(
|
|
83
|
+
"tests/test_foo.py::test_decorated_text",
|
|
84
|
+
"Docstring",
|
|
85
|
+
{"text": "Explicit text"},
|
|
86
|
+
)
|
|
87
|
+
_simulate_collection(plugin, [item])
|
|
88
|
+
_simulate_logstart(plugin, "tests/test_foo.py::test_decorated_text")
|
|
89
|
+
|
|
90
|
+
plugin.backend.update_test_case_text.assert_not_called()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_decorator_fields_do_not_prevent_filling_empty_text(plugin):
|
|
94
|
+
"""Decorator fields other than text do not block the docstring."""
|
|
95
|
+
item = _make_item("tests/test_foo.py::test_decorated_id", "Docstring", {"id": 45})
|
|
96
|
+
_simulate_collection(plugin, [item])
|
|
97
|
+
_simulate_logstart(plugin, "tests/test_foo.py::test_decorated_id")
|
|
98
|
+
|
|
99
|
+
plugin.backend.update_test_case_text.assert_called_once_with(99, "Docstring")
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def test_existing_text_is_not_overwritten_by_docstring(plugin):
|
|
103
|
+
"""Existing TestCase.text must be preserved. Fixes #84."""
|
|
104
|
+
plugin.backend.test_case_get_or_create.return_value = (
|
|
105
|
+
{"id": 99, "text": "Manually written body"},
|
|
106
|
+
True,
|
|
107
|
+
)
|
|
108
|
+
item = _make_item("tests/test_foo.py::test_existing_text", "Docstring")
|
|
109
|
+
_simulate_collection(plugin, [item])
|
|
110
|
+
_simulate_logstart(plugin, "tests/test_foo.py::test_existing_text")
|
|
111
|
+
|
|
112
|
+
plugin.backend.update_test_case_text.assert_not_called()
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def test_empty_text_is_filled_from_docstring(plugin):
|
|
116
|
+
"""An empty TestCase.text must be filled from the docstring."""
|
|
117
|
+
plugin.backend.test_case_get_or_create.return_value = ({"id": 99, "text": ""}, True)
|
|
118
|
+
item = _make_item("tests/test_foo.py::test_empty_text", "Docstring")
|
|
119
|
+
_simulate_collection(plugin, [item])
|
|
120
|
+
_simulate_logstart(plugin, "tests/test_foo.py::test_empty_text")
|
|
121
|
+
|
|
122
|
+
plugin.backend.update_test_case_text.assert_called_once_with(99, "Docstring")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def test_no_update_when_docstring_is_absent(plugin):
|
|
126
|
+
"""update_test_case_text must not be called when the test has no docstring."""
|
|
127
|
+
item = MagicMock()
|
|
128
|
+
item.nodeid = "tests/test_foo.py::test_no_doc"
|
|
129
|
+
item.function.__doc__ = None
|
|
130
|
+
_simulate_collection(plugin, [item])
|
|
131
|
+
_simulate_logstart(plugin, "tests/test_foo.py::test_no_doc")
|
|
132
|
+
|
|
133
|
+
plugin.backend.update_test_case_text.assert_not_called()
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def test_no_update_when_docstring_is_empty_string(plugin):
|
|
137
|
+
"""update_test_case_text must not be called when the docstring is an empty string."""
|
|
138
|
+
items = [_make_item("tests/test_foo.py::test_empty_doc", "")]
|
|
139
|
+
_simulate_collection(plugin, items)
|
|
140
|
+
_simulate_logstart(plugin, "tests/test_foo.py::test_empty_doc")
|
|
141
|
+
|
|
142
|
+
plugin.backend.update_test_case_text.assert_not_called()
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def test_multiline_docstring_is_cleandoc_normalised(plugin):
|
|
146
|
+
"""inspect.cleandoc must be used so internal indentation is normalised."""
|
|
147
|
+
raw_doc = (
|
|
148
|
+
"\n Verify the widget resets on power-up."
|
|
149
|
+
"\n\n Precondition: widget is powered.\n "
|
|
150
|
+
)
|
|
151
|
+
items = [_make_item("tests/test_foo.py::test_multiline", raw_doc)]
|
|
152
|
+
_simulate_collection(plugin, items)
|
|
153
|
+
_simulate_logstart(plugin, "tests/test_foo.py::test_multiline")
|
|
154
|
+
|
|
155
|
+
expected = (
|
|
156
|
+
"Verify the widget resets on power-up.\n\nPrecondition: widget is powered."
|
|
157
|
+
)
|
|
158
|
+
plugin.backend.update_test_case_text.assert_called_once_with(99, expected)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def test_item_without_function_attribute_is_skipped(plugin):
|
|
162
|
+
"""Items without a .function attribute (e.g. doctest items) must not crash collection."""
|
|
163
|
+
item = MagicMock(spec=[]) # no attributes at all
|
|
164
|
+
item.nodeid = "tests/test_foo.py::test_synthetic"
|
|
165
|
+
session = MagicMock()
|
|
166
|
+
session.items = [item]
|
|
167
|
+
|
|
168
|
+
plugin.pytest_collection_finish(session) # must not raise
|
|
169
|
+
|
|
170
|
+
plugin.backend.update_test_case_text.assert_not_called()
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def test_docstring_not_sent_for_different_nodeid(plugin):
|
|
174
|
+
"""Docstring for test_a must be sent when test_a runs, but not when test_b runs."""
|
|
175
|
+
item_a = _make_item("tests/test_foo.py::test_a", "Intention A")
|
|
176
|
+
item_b = _make_item("tests/test_foo.py::test_b", None)
|
|
177
|
+
_simulate_collection(plugin, [item_a, item_b])
|
|
178
|
+
|
|
179
|
+
_simulate_logstart(plugin, "tests/test_foo.py::test_a")
|
|
180
|
+
plugin.backend.test_case_get_or_create.assert_called_once_with(
|
|
181
|
+
"tests/test_foo.py::test_a", item_a.function
|
|
182
|
+
)
|
|
183
|
+
plugin.backend.update_test_case_text.assert_called_once_with(99, "Intention A")
|
|
184
|
+
|
|
185
|
+
plugin.backend.test_case_get_or_create.reset_mock()
|
|
186
|
+
plugin.backend.update_test_case_text.reset_mock()
|
|
187
|
+
|
|
188
|
+
_simulate_logstart(plugin, "tests/test_foo.py::test_b")
|
|
189
|
+
plugin.backend.test_case_get_or_create.assert_called_once_with(
|
|
190
|
+
"tests/test_foo.py::test_b", item_b.function
|
|
191
|
+
)
|
|
192
|
+
plugin.backend.update_test_case_text.assert_not_called()
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def test_backend_update_test_case_text_calls_rpc():
|
|
196
|
+
"""Backend.update_test_case_text must call TestCase.update with the text field."""
|
|
197
|
+
backend = Backend.__new__(Backend)
|
|
198
|
+
backend.rpc = MagicMock()
|
|
199
|
+
|
|
200
|
+
backend.update_test_case_text(test_case_id=7, text="Some intention.")
|
|
201
|
+
|
|
202
|
+
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 +0,0 @@
|
|
|
1
|
-
__version__ = "12.8.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|