testit-adapter-pytest 3.3.1__tar.gz → 3.4.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.
Files changed (21) hide show
  1. {testit_adapter_pytest-3.3.1/src/testit_adapter_pytest.egg-info → testit_adapter_pytest-3.4.0}/PKG-INFO +20 -3
  2. testit_adapter_pytest-3.3.1/PKG-INFO → testit_adapter_pytest-3.4.0/README.md +18 -21
  3. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/setup.py +2 -2
  4. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/src/testit_adapter_pytest/listener.py +22 -32
  5. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/src/testit_adapter_pytest/plugin.py +13 -1
  6. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/src/testit_adapter_pytest/utils.py +31 -2
  7. testit_adapter_pytest-3.3.1/README.md → testit_adapter_pytest-3.4.0/src/testit_adapter_pytest.egg-info/PKG-INFO +38 -1
  8. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/src/testit_adapter_pytest.egg-info/SOURCES.txt +1 -4
  9. testit_adapter_pytest-3.4.0/src/testit_adapter_pytest.egg-info/requires.txt +4 -0
  10. testit_adapter_pytest-3.3.1/src/testit_adapter_pytest/fixture_manager.py +0 -60
  11. testit_adapter_pytest-3.3.1/src/testit_adapter_pytest/fixture_storage.py +0 -40
  12. testit_adapter_pytest-3.3.1/src/testit_adapter_pytest/models/fixture.py +0 -24
  13. testit_adapter_pytest-3.3.1/src/testit_adapter_pytest.egg-info/requires.txt +0 -4
  14. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/setup.cfg +0 -0
  15. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/src/testit_adapter_pytest/__init__.py +0 -0
  16. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/src/testit_adapter_pytest/fixture_context.py +0 -0
  17. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/src/testit_adapter_pytest/models/__init__.py +0 -0
  18. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/src/testit_adapter_pytest/models/executable_test.py +0 -0
  19. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/src/testit_adapter_pytest.egg-info/dependency_links.txt +0 -0
  20. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/src/testit_adapter_pytest.egg-info/entry_points.txt +0 -0
  21. {testit_adapter_pytest-3.3.1 → testit_adapter_pytest-3.4.0}/src/testit_adapter_pytest.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: testit-adapter-pytest
3
- Version: 3.3.1
3
+ Version: 3.4.0
4
4
  Summary: Pytest adapter for Test IT
5
5
  Home-page: https://github.com/testit-tms/adapters-python/
6
6
  Author: Integration team
@@ -16,7 +16,7 @@ Description-Content-Type: text/markdown
16
16
  Requires-Dist: pytest
17
17
  Requires-Dist: pytest-xdist
18
18
  Requires-Dist: attrs
19
- Requires-Dist: testit-python-commons==3.3.1
19
+ Requires-Dist: testit-python-commons==3.4.0
20
20
 
21
21
  # Test IT TMS adapter for Pytest
22
22
 
@@ -51,6 +51,7 @@ pip install testit-adapter-pytest
51
51
  | It enables/disables certificate validation (**It's optional**). Default value - true | certValidation | TMS_CERT_VALIDATION | tmsCertValidation |
52
52
  | Mode of automatic creation test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will create a test case linked to the created autotest (not to the updated autotest)<br/>false - in this mode, the adapter will not create a test case | automaticCreationTestCases | TMS_AUTOMATIC_CREATION_TEST_CASES | tmsAutomaticCreationTestCases |
53
53
  | Mode of automatic updation links to test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will update links to test cases<br/>false - in this mode, the adapter will not update link to test cases | automaticUpdationLinksToTestCases | TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES | tmsAutomaticUpdationLinksToTestCases |
54
+ | Mode of import type selection when launching autotests (**It's optional**). Default value - true. The adapter supports following modes:<br/>true - in this mode, the adapter will create/update each autotest in real time<br/>false - in this mode, the adapter will create/update multiple autotests | importRealtime | TMS_IMPORT_REALTIME | tmsImportRealtime |
54
55
  | Url of proxy server (**It's optional**) | tmsProxy | TMS_PROXY | tmsProxy |
55
56
  | Name of the configuration file If it is not provided, it is used default file name (**It's optional**) | - | TMS_CONFIG_FILE | tmsConfigFile |
56
57
 
@@ -69,6 +70,7 @@ adapterMode = ADAPTER_MODE
69
70
  certValidation = CERT_VALIDATION
70
71
  automaticCreationTestCases = AUTOMATIC_CREATION_TEST_CASES
71
72
  automaticUpdationLinksToTestCases = AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES
73
+ importRealtime = IMPORT_REALTIME
72
74
 
73
75
  # This section are optional. It enables debug mode.
74
76
  [debug]
@@ -86,12 +88,27 @@ $ pytest --testit
86
88
  Launch with command-line parameters:
87
89
 
88
90
  ```
89
- $ pytest --testit --tmsUrl=URL --tmsPrivateToken=USER_PRIVATE_TOKEN --tmsProjectId=PROJECT_ID --tmsConfigurationId=CONFIGURATION_ID --tmsTestRunId=TEST_RUN_ID --tmsTestRunName=TEST_RUN_NAME --tmsAdapterMode=ADAPTER_MODE --tmsProxy='{"http":"http://localhost:8888","https":"http://localhost:8888"}' --tmsCertValidation=CERT_VALIDATION --tmsAutomaticCreationTestCases=AUTOMATIC_CREATION_TEST_CASES --tmsAutomaticUpdationLinksToTestCases=AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES
91
+ $ pytest --testit --tmsUrl=URL --tmsPrivateToken=USER_PRIVATE_TOKEN --tmsProjectId=PROJECT_ID --tmsConfigurationId=CONFIGURATION_ID --tmsTestRunId=TEST_RUN_ID --tmsTestRunName=TEST_RUN_NAME --tmsAdapterMode=ADAPTER_MODE --tmsProxy='{"http":"http://localhost:8888","https":"http://localhost:8888"}' --tmsCertValidation=CERT_VALIDATION --tmsAutomaticCreationTestCases=AUTOMATIC_CREATION_TEST_CASES --tmsAutomaticUpdationLinksToTestCases=AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES --tmsImportRealtime=IMPORT_REALTIME
90
92
  ```
91
93
 
92
94
  If you want to enable debug mode then
93
95
  see [How to enable debug logging?](https://github.com/testit-tms/adapters-python/tree/main/testit-python-commons)
94
96
 
97
+ #### Run with filter
98
+ To create filter by autotests you can use the Test IT CLI (use adapterMode 1 for run with filter):
99
+
100
+ ```
101
+ $ export TMS_TOKEN=<YOUR_TOKEN>
102
+ $ testit autotests_filter
103
+ --url https://tms.testit.software \
104
+ --configuration-id 5236eb3f-7c05-46f9-a609-dc0278896464 \
105
+ --testrun-id 6d4ac4b7-dd67-4805-b879-18da0b89d4a8 \
106
+ --framework pytest \
107
+ --output tmp/filter.txt
108
+
109
+ $ pytest "$(cat tmp/filter.txt)" --tmsTestRunId=6d4ac4b7-dd67-4805-b879-18da0b89d4a8 --tmsAdapterMode=1 --testit
110
+ ```
111
+
95
112
  ### Decorators
96
113
 
97
114
  Decorators can be used to specify information about autotest.
@@ -1,23 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: testit-adapter-pytest
3
- Version: 3.3.1
4
- Summary: Pytest adapter for Test IT
5
- Home-page: https://github.com/testit-tms/adapters-python/
6
- Author: Integration team
7
- Author-email: integrations@testit.software
8
- License: Apache-2.0
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.8
11
- Classifier: Programming Language :: Python :: 3.9
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Description-Content-Type: text/markdown
16
- Requires-Dist: pytest
17
- Requires-Dist: pytest-xdist
18
- Requires-Dist: attrs
19
- Requires-Dist: testit-python-commons==3.3.1
20
-
21
1
  # Test IT TMS adapter for Pytest
22
2
 
23
3
  ![Test IT](https://raw.githubusercontent.com/testit-tms/adapters-python/master/images/banner.png)
@@ -51,6 +31,7 @@ pip install testit-adapter-pytest
51
31
  | It enables/disables certificate validation (**It's optional**). Default value - true | certValidation | TMS_CERT_VALIDATION | tmsCertValidation |
52
32
  | Mode of automatic creation test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will create a test case linked to the created autotest (not to the updated autotest)<br/>false - in this mode, the adapter will not create a test case | automaticCreationTestCases | TMS_AUTOMATIC_CREATION_TEST_CASES | tmsAutomaticCreationTestCases |
53
33
  | Mode of automatic updation links to test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will update links to test cases<br/>false - in this mode, the adapter will not update link to test cases | automaticUpdationLinksToTestCases | TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES | tmsAutomaticUpdationLinksToTestCases |
34
+ | Mode of import type selection when launching autotests (**It's optional**). Default value - true. The adapter supports following modes:<br/>true - in this mode, the adapter will create/update each autotest in real time<br/>false - in this mode, the adapter will create/update multiple autotests | importRealtime | TMS_IMPORT_REALTIME | tmsImportRealtime |
54
35
  | Url of proxy server (**It's optional**) | tmsProxy | TMS_PROXY | tmsProxy |
55
36
  | Name of the configuration file If it is not provided, it is used default file name (**It's optional**) | - | TMS_CONFIG_FILE | tmsConfigFile |
56
37
 
@@ -69,6 +50,7 @@ adapterMode = ADAPTER_MODE
69
50
  certValidation = CERT_VALIDATION
70
51
  automaticCreationTestCases = AUTOMATIC_CREATION_TEST_CASES
71
52
  automaticUpdationLinksToTestCases = AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES
53
+ importRealtime = IMPORT_REALTIME
72
54
 
73
55
  # This section are optional. It enables debug mode.
74
56
  [debug]
@@ -86,12 +68,27 @@ $ pytest --testit
86
68
  Launch with command-line parameters:
87
69
 
88
70
  ```
89
- $ pytest --testit --tmsUrl=URL --tmsPrivateToken=USER_PRIVATE_TOKEN --tmsProjectId=PROJECT_ID --tmsConfigurationId=CONFIGURATION_ID --tmsTestRunId=TEST_RUN_ID --tmsTestRunName=TEST_RUN_NAME --tmsAdapterMode=ADAPTER_MODE --tmsProxy='{"http":"http://localhost:8888","https":"http://localhost:8888"}' --tmsCertValidation=CERT_VALIDATION --tmsAutomaticCreationTestCases=AUTOMATIC_CREATION_TEST_CASES --tmsAutomaticUpdationLinksToTestCases=AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES
71
+ $ pytest --testit --tmsUrl=URL --tmsPrivateToken=USER_PRIVATE_TOKEN --tmsProjectId=PROJECT_ID --tmsConfigurationId=CONFIGURATION_ID --tmsTestRunId=TEST_RUN_ID --tmsTestRunName=TEST_RUN_NAME --tmsAdapterMode=ADAPTER_MODE --tmsProxy='{"http":"http://localhost:8888","https":"http://localhost:8888"}' --tmsCertValidation=CERT_VALIDATION --tmsAutomaticCreationTestCases=AUTOMATIC_CREATION_TEST_CASES --tmsAutomaticUpdationLinksToTestCases=AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES --tmsImportRealtime=IMPORT_REALTIME
90
72
  ```
91
73
 
92
74
  If you want to enable debug mode then
93
75
  see [How to enable debug logging?](https://github.com/testit-tms/adapters-python/tree/main/testit-python-commons)
94
76
 
77
+ #### Run with filter
78
+ To create filter by autotests you can use the Test IT CLI (use adapterMode 1 for run with filter):
79
+
80
+ ```
81
+ $ export TMS_TOKEN=<YOUR_TOKEN>
82
+ $ testit autotests_filter
83
+ --url https://tms.testit.software \
84
+ --configuration-id 5236eb3f-7c05-46f9-a609-dc0278896464 \
85
+ --testrun-id 6d4ac4b7-dd67-4805-b879-18da0b89d4a8 \
86
+ --framework pytest \
87
+ --output tmp/filter.txt
88
+
89
+ $ pytest "$(cat tmp/filter.txt)" --tmsTestRunId=6d4ac4b7-dd67-4805-b879-18da0b89d4a8 --tmsAdapterMode=1 --testit
90
+ ```
91
+
95
92
  ### Decorators
96
93
 
97
94
  Decorators can be used to specify information about autotest.
@@ -2,7 +2,7 @@ from setuptools import find_packages, setup
2
2
 
3
3
  setup(
4
4
  name='testit-adapter-pytest',
5
- version='3.3.1',
5
+ version='3.4.0',
6
6
  description='Pytest adapter for Test IT',
7
7
  long_description=open('README.md', "r").read(),
8
8
  long_description_content_type="text/markdown",
@@ -21,6 +21,6 @@ setup(
21
21
  py_modules=['testit_adapter_pytest'],
22
22
  packages=find_packages(where='src'),
23
23
  package_dir={'': 'src'},
24
- install_requires=['pytest', 'pytest-xdist', 'attrs', 'testit-python-commons==3.3.1'],
24
+ install_requires=['pytest', 'pytest-xdist', 'attrs', 'testit-python-commons==3.4.0'],
25
25
  entry_points={'pytest11': ['testit_adapter_pytest = testit_adapter_pytest.plugin']}
26
26
  )
@@ -8,14 +8,12 @@ import pytest
8
8
 
9
9
  import testit_python_commons.services as adapter
10
10
  from testit_python_commons.models.outcome_type import OutcomeType
11
- from testit_python_commons.services import AdapterManager
12
- from testit_python_commons.services import StepManager
11
+ from testit_python_commons.models.fixture import FixtureResult, FixturesContainer
12
+ from testit_python_commons.services import AdapterManager, StepManager, FixtureManager
13
13
  from testit_python_commons.services.logger import adapter_logger
14
14
 
15
15
  import testit_adapter_pytest.utils as utils
16
16
  from testit_adapter_pytest.fixture_context import FixtureContext
17
- from testit_adapter_pytest.fixture_manager import FixtureManager
18
- from testit_adapter_pytest.models.fixture import FixtureResult, FixturesContainer
19
17
 
20
18
  STATUS = {
21
19
  'passed': OutcomeType.PASSED,
@@ -66,12 +64,11 @@ class TmsListener(object):
66
64
  __pytest_check_info = None
67
65
  __failures = None
68
66
 
69
- def __init__(self, adapter_manager: AdapterManager, step_manager: StepManager):
67
+ def __init__(self, adapter_manager: AdapterManager, step_manager: StepManager, fixture_manager: FixtureManager):
70
68
  self.__adapter_manager = adapter_manager
71
69
  self.__step_manager = step_manager
72
- self.fixture_manager = FixtureManager()
70
+ self.__fixture_manager = fixture_manager
73
71
  self._cache = ItemCache()
74
- self.__test_result_ids = {}
75
72
 
76
73
  @pytest.hookimpl
77
74
  def pytest_configure(self, config):
@@ -189,21 +186,21 @@ class TmsListener(object):
189
186
  if not container_uuid:
190
187
  container_uuid = self._cache.push(fixturedef)
191
188
  container = FixturesContainer(uuid=container_uuid)
192
- self.fixture_manager.start_group(container_uuid, container)
189
+ self.__fixture_manager.start_group(container_uuid, container)
193
190
 
194
- self.fixture_manager.update_group(container_uuid)
191
+ self.__fixture_manager.update_group(container_uuid)
195
192
 
196
193
  before_fixture_uuid = uuid4()
197
194
  before_fixture = FixtureResult(title=fixture_name)
198
195
 
199
- self.fixture_manager.start_before_fixture(container_uuid, before_fixture_uuid, before_fixture)
196
+ self.__fixture_manager.start_before_fixture(container_uuid, before_fixture_uuid, before_fixture)
200
197
 
201
198
  outcome = yield
202
199
 
203
200
  results_steps_data = self.__step_manager.get_steps_tree()
204
201
 
205
- self.fixture_manager.stop_before_fixture(before_fixture_uuid,
206
- outcome=utils.get_outcome_status(outcome), steps=results_steps_data)
202
+ self.__fixture_manager.stop_before_fixture(before_fixture_uuid,
203
+ outcome=utils.get_outcome_status(outcome), steps=results_steps_data)
207
204
 
208
205
  finalizers = getattr(fixturedef, '_finalizers', [])
209
206
  for index, finalizer in enumerate(finalizers):
@@ -230,7 +227,7 @@ class TmsListener(object):
230
227
 
231
228
  if hasattr(fixturedef, 'cached_result') and self._cache.get(fixturedef):
232
229
  group_uuid = self._cache.pop(fixturedef)
233
- self.fixture_manager.stop_group(group_uuid)
230
+ self.__fixture_manager.stop_group(group_uuid)
234
231
 
235
232
  @pytest.hookimpl
236
233
  def pytest_runtest_logreport(self, report):
@@ -257,19 +254,12 @@ class TmsListener(object):
257
254
  if not self.__executable_test:
258
255
  return
259
256
 
260
- self.__test_result_ids[self.__executable_test.node_id] = self.__adapter_manager.write_test(
257
+ self.__adapter_manager.write_test(
261
258
  utils.convert_executable_test_to_test_result_model(self.__executable_test))
262
259
 
263
260
  @pytest.hookimpl
264
261
  def pytest_sessionfinish(self, session):
265
- if not self.__test_result_ids:
266
- return
267
-
268
- self.__adapter_manager.load_setup_and_teardown_step_results(
269
- utils.fixtures_containers_to_test_results_with_all_fixture_step_results(
270
- self.fixture_manager.get_all_items(),
271
- self.__test_result_ids
272
- ))
262
+ self.__adapter_manager.write_tests()
273
263
 
274
264
  @adapter.hookimpl
275
265
  def add_link(self, link):
@@ -294,29 +284,29 @@ class TmsListener(object):
294
284
  @adapter.hookimpl
295
285
  def start_fixture(self, parent_uuid, uuid, title):
296
286
  after_fixture = FixtureResult(title=title)
297
- self.fixture_manager.start_after_fixture(parent_uuid, uuid, after_fixture)
287
+ self.__fixture_manager.start_after_fixture(parent_uuid, uuid, after_fixture)
298
288
 
299
289
  @adapter.hookimpl
300
290
  def stop_fixture(self, uuid, exc_type, exc_val, exc_tb):
301
291
  results_steps_data = self.__step_manager.get_steps_tree()
302
292
 
303
- self.fixture_manager.stop_after_fixture(uuid,
304
- outcome=utils.get_status(exc_val),
305
- steps=results_steps_data,
306
- message=utils.get_message(exc_type, exc_val),
307
- stacktrace=utils.get_traceback(exc_tb))
293
+ self.__fixture_manager.stop_after_fixture(uuid,
294
+ outcome=utils.get_status(exc_val),
295
+ steps=results_steps_data,
296
+ message=utils.get_message(exc_type, exc_val),
297
+ stacktrace=utils.get_traceback(exc_tb))
308
298
 
309
299
  def _update_fixtures_external_ids(self, item):
310
300
  for fixturedef in self._test_fixtures(item):
311
301
  group_uuid = self._cache.get(fixturedef)
312
302
  if group_uuid:
313
- group = self.fixture_manager.get_item(group_uuid)
303
+ group = self.__fixture_manager.get_item(group_uuid)
314
304
  else:
315
305
  group_uuid = self._cache.push(fixturedef)
316
306
  group = FixturesContainer(uuid=group_uuid)
317
- self.fixture_manager.start_group(group_uuid, group)
318
- if item.nodeid not in group.node_ids:
319
- self.fixture_manager.update_group(group_uuid, node_ids=item.nodeid)
307
+ self.__fixture_manager.start_group(group_uuid, group)
308
+ if self.__executable_test.external_id not in group.external_ids:
309
+ self.__fixture_manager.update_group(group_uuid, external_ids=self.__executable_test.external_id)
320
310
 
321
311
  def _test_fixtures(self, item):
322
312
  fixturemanager = item.session._fixturemanager
@@ -109,6 +109,17 @@ def pytest_addoption(parser):
109
109
  false - not update links to test cases (Default)
110
110
  """
111
111
  )
112
+ parser.getgroup('testit').addoption(
113
+ '--tmsImportRealtime',
114
+ action="store",
115
+ dest="set_import_realtime",
116
+ metavar="false",
117
+ help="""
118
+ Set mode of import type selection when launching autotests (optional):
119
+ true - the adapter will create/update each autotest in real time (Default)
120
+ false - the adapter will create/update multiple autotests
121
+ """
122
+ )
112
123
 
113
124
 
114
125
  @pytest.mark.tryfirst
@@ -116,7 +127,8 @@ def pytest_cmdline_main(config):
116
127
  if config.option.tms_report:
117
128
  listener = TmsListener(
118
129
  TmsPluginManager.get_adapter_manager(config.option),
119
- TmsPluginManager.get_step_manager())
130
+ TmsPluginManager.get_step_manager(),
131
+ TmsPluginManager.get_fixture_manager())
120
132
 
121
133
  config.pluginmanager.register(listener)
122
134
  TmsPluginManager.get_plugin_manager().register(listener)
@@ -295,6 +295,8 @@ def get_hash(value: str):
295
295
 
296
296
 
297
297
  def convert_executable_test_to_test_result_model(executable_test: ExecutableTest) -> TestResult:
298
+ pytest_autotest_keys = convert_node_id_to_pytest_autotest_keys(executable_test.node_id)
299
+
298
300
  return TestResult()\
299
301
  .set_external_id(executable_test.external_id)\
300
302
  .set_autotest_name(executable_test.name)\
@@ -314,8 +316,35 @@ def convert_executable_test_to_test_result_model(executable_test: ExecutableTest
314
316
  .set_links(executable_test.links)\
315
317
  .set_result_links(executable_test.result_links)\
316
318
  .set_labels(executable_test.labels)\
317
- .set_work_item_ids(executable_test.work_item_ids)\
318
- .set_message(executable_test.message)
319
+ .set_work_item_ids(executable_test.work_item_ids) \
320
+ .set_message(executable_test.message) \
321
+ .set_external_key(pytest_autotest_keys)
322
+
323
+
324
+ def convert_node_id_to_pytest_autotest_keys(node_id: str) -> str:
325
+ test_path_parts = __get_test_path_parts_by_node_id(node_id)
326
+ directories_in_project = __get_directories_in_project_by_test_path_parts(test_path_parts)
327
+ test_node_parts_from_module = __get_test_node_parts_from_module_by_test_path_parts(test_path_parts)
328
+
329
+ return __join_test_node_parts_to_pytest_autotest_keys(directories_in_project + test_node_parts_from_module)
330
+
331
+
332
+ def __get_test_path_parts_by_node_id(node_id: str):
333
+ return node_id.split('/')
334
+
335
+
336
+ def __get_directories_in_project_by_test_path_parts(test_path_parts: typing.List[str]):
337
+ return test_path_parts[:-1]
338
+
339
+
340
+ def __get_test_node_parts_from_module_by_test_path_parts(test_path_parts: typing.List[str]):
341
+ test_node_from_module = test_path_parts[-1]
342
+
343
+ return test_node_from_module.split('::')
344
+
345
+
346
+ def __join_test_node_parts_to_pytest_autotest_keys(test_node_parts: typing.List[str]):
347
+ return ' and '.join(test_node_parts)
319
348
 
320
349
 
321
350
  def fixtures_containers_to_test_results_with_all_fixture_step_results(
@@ -1,3 +1,23 @@
1
+ Metadata-Version: 2.1
2
+ Name: testit-adapter-pytest
3
+ Version: 3.4.0
4
+ Summary: Pytest adapter for Test IT
5
+ Home-page: https://github.com/testit-tms/adapters-python/
6
+ Author: Integration team
7
+ Author-email: integrations@testit.software
8
+ License: Apache-2.0
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.8
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: pytest
17
+ Requires-Dist: pytest-xdist
18
+ Requires-Dist: attrs
19
+ Requires-Dist: testit-python-commons==3.4.0
20
+
1
21
  # Test IT TMS adapter for Pytest
2
22
 
3
23
  ![Test IT](https://raw.githubusercontent.com/testit-tms/adapters-python/master/images/banner.png)
@@ -31,6 +51,7 @@ pip install testit-adapter-pytest
31
51
  | It enables/disables certificate validation (**It's optional**). Default value - true | certValidation | TMS_CERT_VALIDATION | tmsCertValidation |
32
52
  | Mode of automatic creation test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will create a test case linked to the created autotest (not to the updated autotest)<br/>false - in this mode, the adapter will not create a test case | automaticCreationTestCases | TMS_AUTOMATIC_CREATION_TEST_CASES | tmsAutomaticCreationTestCases |
33
53
  | Mode of automatic updation links to test cases (**It's optional**). Default value - false. The adapter supports following modes:<br/>true - in this mode, the adapter will update links to test cases<br/>false - in this mode, the adapter will not update link to test cases | automaticUpdationLinksToTestCases | TMS_AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES | tmsAutomaticUpdationLinksToTestCases |
54
+ | Mode of import type selection when launching autotests (**It's optional**). Default value - true. The adapter supports following modes:<br/>true - in this mode, the adapter will create/update each autotest in real time<br/>false - in this mode, the adapter will create/update multiple autotests | importRealtime | TMS_IMPORT_REALTIME | tmsImportRealtime |
34
55
  | Url of proxy server (**It's optional**) | tmsProxy | TMS_PROXY | tmsProxy |
35
56
  | Name of the configuration file If it is not provided, it is used default file name (**It's optional**) | - | TMS_CONFIG_FILE | tmsConfigFile |
36
57
 
@@ -49,6 +70,7 @@ adapterMode = ADAPTER_MODE
49
70
  certValidation = CERT_VALIDATION
50
71
  automaticCreationTestCases = AUTOMATIC_CREATION_TEST_CASES
51
72
  automaticUpdationLinksToTestCases = AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES
73
+ importRealtime = IMPORT_REALTIME
52
74
 
53
75
  # This section are optional. It enables debug mode.
54
76
  [debug]
@@ -66,12 +88,27 @@ $ pytest --testit
66
88
  Launch with command-line parameters:
67
89
 
68
90
  ```
69
- $ pytest --testit --tmsUrl=URL --tmsPrivateToken=USER_PRIVATE_TOKEN --tmsProjectId=PROJECT_ID --tmsConfigurationId=CONFIGURATION_ID --tmsTestRunId=TEST_RUN_ID --tmsTestRunName=TEST_RUN_NAME --tmsAdapterMode=ADAPTER_MODE --tmsProxy='{"http":"http://localhost:8888","https":"http://localhost:8888"}' --tmsCertValidation=CERT_VALIDATION --tmsAutomaticCreationTestCases=AUTOMATIC_CREATION_TEST_CASES --tmsAutomaticUpdationLinksToTestCases=AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES
91
+ $ pytest --testit --tmsUrl=URL --tmsPrivateToken=USER_PRIVATE_TOKEN --tmsProjectId=PROJECT_ID --tmsConfigurationId=CONFIGURATION_ID --tmsTestRunId=TEST_RUN_ID --tmsTestRunName=TEST_RUN_NAME --tmsAdapterMode=ADAPTER_MODE --tmsProxy='{"http":"http://localhost:8888","https":"http://localhost:8888"}' --tmsCertValidation=CERT_VALIDATION --tmsAutomaticCreationTestCases=AUTOMATIC_CREATION_TEST_CASES --tmsAutomaticUpdationLinksToTestCases=AUTOMATIC_UPDATION_LINKS_TO_TEST_CASES --tmsImportRealtime=IMPORT_REALTIME
70
92
  ```
71
93
 
72
94
  If you want to enable debug mode then
73
95
  see [How to enable debug logging?](https://github.com/testit-tms/adapters-python/tree/main/testit-python-commons)
74
96
 
97
+ #### Run with filter
98
+ To create filter by autotests you can use the Test IT CLI (use adapterMode 1 for run with filter):
99
+
100
+ ```
101
+ $ export TMS_TOKEN=<YOUR_TOKEN>
102
+ $ testit autotests_filter
103
+ --url https://tms.testit.software \
104
+ --configuration-id 5236eb3f-7c05-46f9-a609-dc0278896464 \
105
+ --testrun-id 6d4ac4b7-dd67-4805-b879-18da0b89d4a8 \
106
+ --framework pytest \
107
+ --output tmp/filter.txt
108
+
109
+ $ pytest "$(cat tmp/filter.txt)" --tmsTestRunId=6d4ac4b7-dd67-4805-b879-18da0b89d4a8 --tmsAdapterMode=1 --testit
110
+ ```
111
+
75
112
  ### Decorators
76
113
 
77
114
  Decorators can be used to specify information about autotest.
@@ -2,8 +2,6 @@ README.md
2
2
  setup.py
3
3
  src/testit_adapter_pytest/__init__.py
4
4
  src/testit_adapter_pytest/fixture_context.py
5
- src/testit_adapter_pytest/fixture_manager.py
6
- src/testit_adapter_pytest/fixture_storage.py
7
5
  src/testit_adapter_pytest/listener.py
8
6
  src/testit_adapter_pytest/plugin.py
9
7
  src/testit_adapter_pytest/utils.py
@@ -14,5 +12,4 @@ src/testit_adapter_pytest.egg-info/entry_points.txt
14
12
  src/testit_adapter_pytest.egg-info/requires.txt
15
13
  src/testit_adapter_pytest.egg-info/top_level.txt
16
14
  src/testit_adapter_pytest/models/__init__.py
17
- src/testit_adapter_pytest/models/executable_test.py
18
- src/testit_adapter_pytest/models/fixture.py
15
+ src/testit_adapter_pytest/models/executable_test.py
@@ -0,0 +1,4 @@
1
+ pytest
2
+ pytest-xdist
3
+ attrs
4
+ testit-python-commons==3.4.0
@@ -1,60 +0,0 @@
1
- from testit_adapter_pytest.fixture_storage import ThreadContextFixtures
2
- from testit_adapter_pytest.models.fixture import FixtureResult
3
-
4
-
5
- class FixtureManager:
6
- def __init__(self):
7
- self._items = ThreadContextFixtures()
8
- self._orphan_items = []
9
-
10
- def _update_item(self, uuid, **kwargs):
11
- item = self._items[uuid] if uuid else self._items[next(reversed(self._items))]
12
- for name, value in kwargs.items():
13
- attr = getattr(item, name)
14
- if isinstance(attr, list):
15
- attr.append(value)
16
- else:
17
- setattr(item, name, value)
18
-
19
- def _last_executable(self):
20
- for _uuid in reversed(self._items):
21
- if isinstance(self._items[_uuid], FixtureResult):
22
- return _uuid
23
-
24
- def get_item(self, uuid):
25
- return self._items.get(uuid)
26
-
27
- def get_last_item(self, item_type=None):
28
- for _uuid in reversed(self._items):
29
- if item_type is None:
30
- return self._items.get(_uuid)
31
- if type(self._items[_uuid]) == item_type:
32
- return self._items.get(_uuid)
33
-
34
- def start_group(self, uuid, group):
35
- self._items[uuid] = group
36
-
37
- def stop_group(self, uuid, **kwargs):
38
- self._update_item(uuid, **kwargs)
39
-
40
- def update_group(self, uuid, **kwargs):
41
- self._update_item(uuid, **kwargs)
42
-
43
- def start_before_fixture(self, parent_uuid, uuid, fixture):
44
- self._items.get(parent_uuid).befores.append(fixture)
45
- self._items[uuid] = fixture
46
-
47
- def stop_before_fixture(self, uuid, **kwargs):
48
- self._update_item(uuid, **kwargs)
49
- self._items.pop(uuid)
50
-
51
- def start_after_fixture(self, parent_uuid, uuid, fixture):
52
- self._items.get(parent_uuid).afters.append(fixture)
53
- self._items[uuid] = fixture
54
-
55
- def stop_after_fixture(self, uuid, **kwargs):
56
- self._update_item(uuid, **kwargs)
57
- self._items.pop(uuid)
58
-
59
- def get_all_items(self):
60
- return self._items.get_all()
@@ -1,40 +0,0 @@
1
- import threading
2
- from collections import OrderedDict, defaultdict
3
-
4
-
5
- class ThreadContextFixtures:
6
- _thread_context = defaultdict(OrderedDict)
7
- _init_thread: threading.Thread
8
-
9
- @property
10
- def thread_context(self):
11
- context = self._thread_context[threading.current_thread()]
12
- if not context and threading.current_thread() is not self._init_thread:
13
- uuid, last_item = next(reversed(self._thread_context[self._init_thread].items()))
14
- context[uuid] = last_item
15
- return context
16
-
17
- def __init__(self, *args, **kwargs):
18
- self._init_thread = threading.current_thread()
19
- super().__init__(*args, **kwargs)
20
-
21
- def __setitem__(self, key, value):
22
- self.thread_context.__setitem__(key, value)
23
-
24
- def __getitem__(self, item):
25
- return self.thread_context.__getitem__(item)
26
-
27
- def __iter__(self):
28
- return self.thread_context.__iter__()
29
-
30
- def __reversed__(self):
31
- return self.thread_context.__reversed__()
32
-
33
- def get(self, key):
34
- return self.thread_context.get(key)
35
-
36
- def pop(self, key):
37
- return self.thread_context.pop(key)
38
-
39
- def get_all(self):
40
- return dict(self.thread_context.items())
@@ -1,24 +0,0 @@
1
- from attr import attrs, attrib
2
- from attr import Factory
3
-
4
-
5
- @attrs
6
- class FixtureResult:
7
- title = attrib(default=None)
8
- outcome = attrib(default=None)
9
- description = attrib(default=None)
10
- message = attrib(default=None)
11
- stacktrace = attrib(default=None)
12
- steps = attrib(default=None)
13
- attachments = attrib(default=Factory(list))
14
- parameters = attrib(default=Factory(list))
15
- start = attrib(default=None)
16
- stop = attrib(default=None)
17
-
18
-
19
- @attrs
20
- class FixturesContainer:
21
- uuid = attrib(default=None)
22
- node_ids = attrib(default=Factory(list))
23
- befores = attrib(default=Factory(list))
24
- afters = attrib(default=Factory(list))
@@ -1,4 +0,0 @@
1
- pytest
2
- pytest-xdist
3
- attrs
4
- testit-python-commons==3.3.1