testit-adapter-pytest 3.0.1__tar.gz → 3.1.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.0.1 → testit_adapter_pytest-3.1.0}/PKG-INFO +2 -4
  2. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/setup.py +2 -4
  3. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest/listener.py +31 -35
  4. testit_adapter_pytest-3.1.0/src/testit_adapter_pytest/models/executable_test.py +31 -0
  5. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest/models/fixture.py +1 -1
  6. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest/utils.py +48 -58
  7. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest.egg-info/PKG-INFO +2 -4
  8. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest.egg-info/SOURCES.txt +1 -0
  9. testit_adapter_pytest-3.1.0/src/testit_adapter_pytest.egg-info/requires.txt +4 -0
  10. testit_adapter_pytest-3.0.1/src/testit_adapter_pytest.egg-info/requires.txt +0 -4
  11. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/README.md +0 -0
  12. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/setup.cfg +0 -0
  13. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest/__init__.py +0 -0
  14. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest/fixture_context.py +0 -0
  15. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest/fixture_manager.py +0 -0
  16. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest/fixture_storage.py +0 -0
  17. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest/models/__init__.py +0 -0
  18. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest/plugin.py +0 -0
  19. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest.egg-info/dependency_links.txt +0 -0
  20. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest.egg-info/entry_points.txt +0 -0
  21. {testit_adapter_pytest-3.0.1 → testit_adapter_pytest-3.1.0}/src/testit_adapter_pytest.egg-info/top_level.txt +0 -0
@@ -1,14 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: testit-adapter-pytest
3
- Version: 3.0.1
3
+ Version: 3.1.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
7
7
  Author-email: integrations@testit.software
8
8
  License: Apache-2.0
9
9
  Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.6
11
- Classifier: Programming Language :: Python :: 3.7
12
10
  Classifier: Programming Language :: Python :: 3.8
13
11
  Classifier: Programming Language :: Python :: 3.9
14
12
  Classifier: Programming Language :: Python :: 3.10
@@ -18,7 +16,7 @@ Description-Content-Type: text/markdown
18
16
  Requires-Dist: pytest
19
17
  Requires-Dist: pytest-xdist
20
18
  Requires-Dist: attrs
21
- Requires-Dist: testit-python-commons==3.0.1
19
+ Requires-Dist: testit-python-commons==3.1.0
22
20
 
23
21
  # Test IT TMS adapter for Pytest
24
22
 
@@ -2,7 +2,7 @@ from setuptools import find_packages, setup
2
2
 
3
3
  setup(
4
4
  name='testit-adapter-pytest',
5
- version='3.0.1',
5
+ version='3.1.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",
@@ -12,8 +12,6 @@ setup(
12
12
  license='Apache-2.0',
13
13
  classifiers=[
14
14
  'Programming Language :: Python :: 3',
15
- 'Programming Language :: Python :: 3.6',
16
- 'Programming Language :: Python :: 3.7',
17
15
  'Programming Language :: Python :: 3.8',
18
16
  'Programming Language :: Python :: 3.9',
19
17
  'Programming Language :: Python :: 3.10',
@@ -23,6 +21,6 @@ setup(
23
21
  py_modules=['testit_adapter_pytest'],
24
22
  packages=find_packages(where='src'),
25
23
  package_dir={'': 'src'},
26
- install_requires=['pytest', 'pytest-xdist', 'attrs', 'testit-python-commons==3.0.1'],
24
+ install_requires=['pytest', 'pytest-xdist', 'attrs', 'testit-python-commons==3.1.0'],
27
25
  entry_points={'pytest11': ['testit_adapter_pytest = testit_adapter_pytest.plugin']}
28
26
  )
@@ -1,4 +1,5 @@
1
1
  import pickle
2
+ from importlib.metadata import metadata
2
3
  from uuid import uuid4
3
4
 
4
5
  from packaging import version
@@ -61,6 +62,7 @@ class SeparationOfTests:
61
62
 
62
63
  class TmsListener(object):
63
64
  __executable_test = None
65
+ __pytest_info = None
64
66
  __pytest_check_info = None
65
67
  __failures = None
66
68
 
@@ -73,6 +75,8 @@ class TmsListener(object):
73
75
 
74
76
  @pytest.hookimpl
75
77
  def pytest_configure(self, config):
78
+ self.__pytest_info = metadata("pytest")
79
+
76
80
  if not hasattr(config, "workerinput") and not hasattr(self, "test_run_id"):
77
81
  config.test_run_id = self.__adapter_manager.get_test_run_id()
78
82
  else:
@@ -207,12 +211,6 @@ class TmsListener(object):
207
211
  name = f'{fixture_name}::{finalizer_name}'
208
212
  finalizers[index] = FixtureContext(finalizer, parent_uuid=container_uuid, name=name)
209
213
 
210
- if self.__executable_test:
211
- results_steps_data = self.__step_manager.get_steps_tree()
212
-
213
- if fixturedef.scope == 'function':
214
- self.__executable_test['setUpResults'] += results_steps_data
215
-
216
214
  @pytest.hookimpl(hookwrapper=True, trylast=True)
217
215
  def pytest_runtest_call(self):
218
216
  yield
@@ -221,18 +219,13 @@ class TmsListener(object):
221
219
  return
222
220
 
223
221
  test_results_steps = self.__step_manager.get_steps_tree()
224
- self.__executable_test['stepResults'] = test_results_steps
222
+ self.__executable_test.step_results = test_results_steps
225
223
 
226
224
  @pytest.hookimpl(hookwrapper=True)
227
225
  def pytest_fixture_post_finalizer(self, fixturedef):
228
226
  if not self.__executable_test:
229
227
  return
230
228
 
231
- teardown_results_steps = self.__step_manager.get_steps_tree()
232
-
233
- if fixturedef.scope == 'function':
234
- self.__executable_test['tearDownResults'] += teardown_results_steps
235
-
236
229
  yield
237
230
 
238
231
  if hasattr(fixturedef, 'cached_result') and self._cache.get(fixturedef):
@@ -243,28 +236,28 @@ class TmsListener(object):
243
236
  def pytest_runtest_logreport(self, report):
244
237
  if self.__executable_test:
245
238
  if report.when == 'setup':
246
- self.__executable_test['outcome'] = STATUS.get(report.outcome, None)
239
+ self.__executable_test.outcome = STATUS.get(report.outcome, None)
247
240
  if report.longreprtext:
248
- self.__executable_test['message'] = report.longreprtext
241
+ self.__executable_test.message = report.longreprtext
249
242
 
250
243
  if report.when == 'call':
251
- self.__executable_test['outcome'] = STATUS.get(report.outcome, None)
244
+ self.__executable_test.outcome = STATUS.get(report.outcome, None)
252
245
 
253
246
  if report.failed or hasattr(report, 'wasxfail') \
254
247
  and not report.passed or report.outcome == 'rerun':
255
- self.__executable_test['outcome'] = STATUS.get('failed', None)
248
+ self.__executable_test.outcome = STATUS.get('failed', None)
256
249
 
257
250
  if report.longreprtext:
258
- self.__executable_test['traces'] = report.longreprtext
251
+ self.__executable_test.traces = report.longreprtext
259
252
 
260
- self.__executable_test['duration'] += report.duration * 1000
253
+ self.__executable_test.duration += report.duration * 1000
261
254
 
262
255
  @pytest.hookimpl
263
256
  def pytest_runtest_logfinish(self):
264
257
  if not self.__executable_test:
265
258
  return
266
259
 
267
- self.__test_result_ids[self.__executable_test['externalID']] = self.__adapter_manager.write_test(
260
+ self.__test_result_ids[self.__executable_test.node_id] = self.__adapter_manager.write_test(
268
261
  utils.convert_executable_test_to_test_result_model(self.__executable_test))
269
262
 
270
263
  @pytest.hookimpl
@@ -281,22 +274,22 @@ class TmsListener(object):
281
274
  @adapter.hookimpl
282
275
  def add_link(self, link):
283
276
  if self.__executable_test:
284
- self.__executable_test['resultLinks'].append(link)
277
+ self.__executable_test.result_links.append(link)
285
278
 
286
279
  @adapter.hookimpl
287
280
  def add_message(self, test_message):
288
281
  if self.__executable_test:
289
- self.__executable_test['message'] = str(test_message)
282
+ self.__executable_test.message = str(test_message)
290
283
 
291
284
  @adapter.hookimpl
292
285
  def add_attachments(self, attach_paths: list or tuple):
293
286
  if self.__executable_test:
294
- self.__executable_test['attachments'] += self.__adapter_manager.load_attachments(attach_paths)
287
+ self.__executable_test.attachments += self.__adapter_manager.load_attachments(attach_paths)
295
288
 
296
289
  @adapter.hookimpl
297
290
  def create_attachment(self, body, name: str):
298
291
  if self.__executable_test:
299
- self.__executable_test['attachments'] += self.__adapter_manager.create_attachment(body, name)
292
+ self.__executable_test.attachments += self.__adapter_manager.create_attachment(body, name)
300
293
 
301
294
  @adapter.hookimpl
302
295
  def start_fixture(self, parent_uuid, uuid, title):
@@ -314,7 +307,7 @@ class TmsListener(object):
314
307
  stacktrace=utils.get_traceback(exc_tb))
315
308
 
316
309
  def _update_fixtures_external_ids(self, item):
317
- for fixturedef in _test_fixtures(item):
310
+ for fixturedef in self._test_fixtures(item):
318
311
  group_uuid = self._cache.get(fixturedef)
319
312
  if group_uuid:
320
313
  group = self.fixture_manager.get_item(group_uuid)
@@ -322,18 +315,21 @@ class TmsListener(object):
322
315
  group_uuid = self._cache.push(fixturedef)
323
316
  group = FixturesContainer(uuid=group_uuid)
324
317
  self.fixture_manager.start_group(group_uuid, group)
325
- if item.test_external_id not in group.external_ids:
326
- self.fixture_manager.update_group(group_uuid, external_ids=item.test_external_id)
318
+ if item.nodeid not in group.node_ids:
319
+ self.fixture_manager.update_group(group_uuid, node_ids=item.nodeid)
327
320
 
321
+ def _test_fixtures(self, item):
322
+ fixturemanager = item.session._fixturemanager
323
+ fixturedefs = []
328
324
 
329
- def _test_fixtures(item):
330
- fixturemanager = item.session._fixturemanager
331
- fixturedefs = []
325
+ if hasattr(item, "_request") and hasattr(item._request, "fixturenames"):
326
+ for name in item._request.fixturenames:
327
+ if self.__pytest_info and version.parse(self.__pytest_info["version"]) >= version.parse("8.1.0"):
328
+ fixturedefs_pytest = fixturemanager.getfixturedefs(name, item)
329
+ else:
330
+ fixturedefs_pytest = fixturemanager.getfixturedefs(name, item.nodeid)
332
331
 
333
- if hasattr(item, "_request") and hasattr(item._request, "fixturenames"):
334
- for name in item._request.fixturenames:
335
- fixturedefs_pytest = fixturemanager.getfixturedefs(name, item.nodeid)
336
- if fixturedefs_pytest:
337
- fixturedefs.extend(fixturedefs_pytest)
332
+ if fixturedefs_pytest:
333
+ fixturedefs.extend(fixturedefs_pytest)
338
334
 
339
- return fixturedefs
335
+ return fixturedefs
@@ -0,0 +1,31 @@
1
+ from attr import attrs, attrib
2
+ from attr import Factory
3
+
4
+
5
+ @attrs
6
+ class ExecutableTest:
7
+ external_id = attrib()
8
+ name = attrib()
9
+ steps = attrib(default=Factory(list))
10
+ step_results = attrib(default=Factory(list))
11
+ setup_steps = attrib(default=Factory(list))
12
+ setup_step_results = attrib(default=Factory(list))
13
+ teardown_steps = attrib(default=Factory(list))
14
+ teardown_step_results = attrib(default=Factory(list))
15
+ result_links = attrib(default=Factory(list))
16
+ duration = attrib(default=None)
17
+ outcome = attrib(default=None)
18
+ failure_reason_names = attrib(default=Factory(list))
19
+ traces = attrib(default=None)
20
+ attachments = attrib(default=Factory(list))
21
+ parameters = attrib(default=Factory(dict))
22
+ properties = attrib(default=Factory(dict))
23
+ namespace = attrib(default=None)
24
+ classname = attrib(default=None)
25
+ title = attrib(default=None)
26
+ description = attrib(default=None)
27
+ links = attrib(default=Factory(list))
28
+ labels = attrib(default=Factory(list))
29
+ work_item_ids = attrib(default=Factory(list))
30
+ message = attrib(default=None)
31
+ node_id = attrib(default=None)
@@ -19,6 +19,6 @@ class FixtureResult:
19
19
  @attrs
20
20
  class FixturesContainer:
21
21
  uuid = attrib(default=None)
22
- external_ids = attrib(default=Factory(list))
22
+ node_ids = attrib(default=Factory(list))
23
23
  befores = attrib(default=Factory(list))
24
24
  afters = attrib(default=Factory(list))
@@ -11,54 +11,44 @@ from testit_python_commons.models.link import Link
11
11
  from testit_python_commons.models.test_result import TestResult
12
12
  from testit_python_commons.models.test_result_with_all_fixture_step_results_model import TestResultWithAllFixtureStepResults
13
13
 
14
+ from testit_adapter_pytest.models.executable_test import ExecutableTest
15
+
14
16
 
15
17
  __ARRAY_TYPES = (frozenset, list, set, tuple,)
16
18
 
17
19
 
18
- def form_test(item):
19
- data = {
20
- 'externalID': __get_external_id_from(item),
21
- 'autoTestName': __get_display_name_from(item),
22
- 'steps': [],
23
- 'stepResults': [],
24
- 'setUp': [],
25
- 'setUpResults': [],
26
- 'tearDown': [],
27
- 'tearDownResults': [],
28
- 'resultLinks': [],
29
- 'duration': 0,
30
- 'outcome': None,
31
- 'failureReasonName': None,
32
- 'traces': None,
33
- 'attachments': [],
34
- 'parameters': __get_parameters_from(item),
35
- 'properties': __get_properties_from(item),
36
- 'namespace': __get_namespace_from(item),
37
- 'classname': __get_class_name_from(item),
38
- 'title': __get_title_from(item),
39
- 'description': __get_description_from(item),
40
- 'links': __get_links_from(item),
41
- 'labels': __get_labels_from(item),
42
- 'workItemsID': __get_work_item_ids_from(item),
43
- 'message': None
44
- }
20
+ def form_test(item) -> ExecutableTest:
21
+ executable_test = ExecutableTest(
22
+ external_id=__get_external_id_from(item),
23
+ name=__get_display_name_from(item),
24
+ duration=0,
25
+ parameters=__get_parameters_from(item),
26
+ properties=__get_properties_from(item),
27
+ namespace=__get_namespace_from(item),
28
+ classname=__get_class_name_from(item),
29
+ title=__get_title_from(item),
30
+ description=__get_description_from(item),
31
+ links=__get_links_from(item),
32
+ labels=__get_labels_from(item),
33
+ work_item_ids=__get_work_item_ids_from(item),
34
+ node_id=item.nodeid
35
+ )
45
36
 
46
37
  if item.own_markers:
47
38
  for mark in item.own_markers:
48
39
  if mark.name == 'skip' or mark.name == 'skipif':
49
- data['outcome'] = 'Skipped'
50
- data['failureReasonName'] = None
40
+ executable_test.outcome = 'Skipped'
51
41
  if mark.args:
52
- data['message'] = mark.args[0]
42
+ executable_test.message = mark.args[0]
53
43
  if mark.kwargs and 'reason' in mark.kwargs:
54
- data['message'] = mark.kwargs['reason']
44
+ executable_test.message = mark.kwargs['reason']
55
45
  if mark.name == 'xfail':
56
46
  if mark.args:
57
- data['message'] = mark.args[0]
47
+ executable_test.message = mark.args[0]
58
48
  if mark.kwargs and 'reason' in mark.kwargs:
59
- data['message'] = mark.kwargs['reason']
49
+ executable_test.message = mark.kwargs['reason']
60
50
 
61
- return data
51
+ return executable_test
62
52
 
63
53
 
64
54
  def __get_display_name_from(item):
@@ -131,7 +121,7 @@ def __get_links_from(item):
131
121
 
132
122
 
133
123
  def __get_parameters_from(item):
134
- if hasattr(item, 'array_parametrize_mark_id'):
124
+ if hasattr(item, 'callspec'):
135
125
  test_parameters = {}
136
126
  for key, parameter in item.callspec.params.items():
137
127
  test_parameters[key] = str(parameter)
@@ -299,28 +289,28 @@ def get_hash(value: str):
299
289
  return md.hexdigest()
300
290
 
301
291
 
302
- def convert_executable_test_to_test_result_model(executable_test: dict) -> TestResult:
292
+ def convert_executable_test_to_test_result_model(executable_test: ExecutableTest) -> TestResult:
303
293
  return TestResult()\
304
- .set_external_id(executable_test['externalID'])\
305
- .set_autotest_name(executable_test['autoTestName'])\
306
- .set_step_results(executable_test['stepResults'])\
307
- .set_setup_results(executable_test['setUpResults'])\
308
- .set_teardown_results(executable_test['tearDownResults'])\
309
- .set_duration(executable_test['duration'])\
310
- .set_outcome(executable_test['outcome'])\
311
- .set_traces(executable_test['traces'])\
312
- .set_attachments(executable_test['attachments'])\
313
- .set_parameters(executable_test['parameters'])\
314
- .set_properties(executable_test['properties'])\
315
- .set_namespace(executable_test['namespace'])\
316
- .set_classname(executable_test['classname'])\
317
- .set_title(executable_test['title'])\
318
- .set_description(executable_test['description'])\
319
- .set_links(executable_test['links'])\
320
- .set_result_links(executable_test['resultLinks'])\
321
- .set_labels(executable_test['labels'])\
322
- .set_work_item_ids(executable_test['workItemsID'])\
323
- .set_message(executable_test['message'])
294
+ .set_external_id(executable_test.external_id)\
295
+ .set_autotest_name(executable_test.name)\
296
+ .set_step_results(executable_test.step_results)\
297
+ .set_setup_results(executable_test.setup_step_results)\
298
+ .set_teardown_results(executable_test.teardown_step_results)\
299
+ .set_duration(executable_test.duration)\
300
+ .set_outcome(executable_test.outcome)\
301
+ .set_traces(executable_test.traces)\
302
+ .set_attachments(executable_test.attachments)\
303
+ .set_parameters(executable_test.parameters)\
304
+ .set_properties(executable_test.properties)\
305
+ .set_namespace(executable_test.namespace)\
306
+ .set_classname(executable_test.classname)\
307
+ .set_title(executable_test.title)\
308
+ .set_description(executable_test.description)\
309
+ .set_links(executable_test.links)\
310
+ .set_result_links(executable_test.result_links)\
311
+ .set_labels(executable_test.labels)\
312
+ .set_work_item_ids(executable_test.work_item_ids)\
313
+ .set_message(executable_test.message)
324
314
 
325
315
 
326
316
  def fixtures_containers_to_test_results_with_all_fixture_step_results(
@@ -328,11 +318,11 @@ def fixtures_containers_to_test_results_with_all_fixture_step_results(
328
318
  test_result_ids: dict) -> typing.List[TestResultWithAllFixtureStepResults]:
329
319
  test_results_with_all_fixture_step_results = []
330
320
 
331
- for external_id, test_result_id in test_result_ids.items():
321
+ for node_id, test_result_id in test_result_ids.items():
332
322
  test_result_with_all_fixture_step_results = TestResultWithAllFixtureStepResults(test_result_id)
333
323
 
334
324
  for uuid, fixtures_container in fixtures_containers.items():
335
- if external_id in fixtures_container.external_ids:
325
+ if node_id in fixtures_container.node_ids:
336
326
  if fixtures_container.befores:
337
327
  test_result_with_all_fixture_step_results.set_setup_results(fixtures_container.befores[0].steps)
338
328
 
@@ -1,14 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: testit-adapter-pytest
3
- Version: 3.0.1
3
+ Version: 3.1.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
7
7
  Author-email: integrations@testit.software
8
8
  License: Apache-2.0
9
9
  Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.6
11
- Classifier: Programming Language :: Python :: 3.7
12
10
  Classifier: Programming Language :: Python :: 3.8
13
11
  Classifier: Programming Language :: Python :: 3.9
14
12
  Classifier: Programming Language :: Python :: 3.10
@@ -18,7 +16,7 @@ Description-Content-Type: text/markdown
18
16
  Requires-Dist: pytest
19
17
  Requires-Dist: pytest-xdist
20
18
  Requires-Dist: attrs
21
- Requires-Dist: testit-python-commons==3.0.1
19
+ Requires-Dist: testit-python-commons==3.1.0
22
20
 
23
21
  # Test IT TMS adapter for Pytest
24
22
 
@@ -14,4 +14,5 @@ src/testit_adapter_pytest.egg-info/entry_points.txt
14
14
  src/testit_adapter_pytest.egg-info/requires.txt
15
15
  src/testit_adapter_pytest.egg-info/top_level.txt
16
16
  src/testit_adapter_pytest/models/__init__.py
17
+ src/testit_adapter_pytest/models/executable_test.py
17
18
  src/testit_adapter_pytest/models/fixture.py
@@ -0,0 +1,4 @@
1
+ pytest
2
+ pytest-xdist
3
+ attrs
4
+ testit-python-commons==3.1.0
@@ -1,4 +0,0 @@
1
- pytest
2
- pytest-xdist
3
- attrs
4
- testit-python-commons==3.0.1