testit-adapter-pytest 3.0.0__tar.gz → 3.0.2__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.0 → testit_adapter_pytest-3.0.2}/PKG-INFO +2 -2
  2. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/setup.py +2 -2
  3. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest/listener.py +21 -30
  4. testit_adapter_pytest-3.0.2/src/testit_adapter_pytest/models/executable_test.py +31 -0
  5. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest/models/fixture.py +1 -1
  6. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest/utils.py +48 -58
  7. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest.egg-info/PKG-INFO +2 -2
  8. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest.egg-info/SOURCES.txt +1 -0
  9. testit_adapter_pytest-3.0.2/src/testit_adapter_pytest.egg-info/requires.txt +4 -0
  10. testit_adapter_pytest-3.0.0/src/testit_adapter_pytest.egg-info/requires.txt +0 -4
  11. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/README.md +0 -0
  12. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/setup.cfg +0 -0
  13. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest/__init__.py +0 -0
  14. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest/fixture_context.py +0 -0
  15. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest/fixture_manager.py +0 -0
  16. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest/fixture_storage.py +0 -0
  17. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest/models/__init__.py +0 -0
  18. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest/plugin.py +0 -0
  19. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest.egg-info/dependency_links.txt +0 -0
  20. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/src/testit_adapter_pytest.egg-info/entry_points.txt +0 -0
  21. {testit_adapter_pytest-3.0.0 → testit_adapter_pytest-3.0.2}/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.0.0
3
+ Version: 3.0.2
4
4
  Summary: Pytest adapter for Test IT
5
5
  Home-page: https://github.com/testit-tms/adapters-python/
6
6
  Author: Integration team
@@ -18,7 +18,7 @@ Description-Content-Type: text/markdown
18
18
  Requires-Dist: pytest
19
19
  Requires-Dist: pytest-xdist
20
20
  Requires-Dist: attrs
21
- Requires-Dist: testit-python-commons==3.0.0
21
+ Requires-Dist: testit-python-commons==3.0.2
22
22
 
23
23
  # Test IT TMS adapter for Pytest
24
24
 
@@ -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.0',
5
+ version='3.0.2',
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",
@@ -23,6 +23,6 @@ setup(
23
23
  py_modules=['testit_adapter_pytest'],
24
24
  packages=find_packages(where='src'),
25
25
  package_dir={'': 'src'},
26
- install_requires=['pytest', 'pytest-xdist', 'attrs', 'testit-python-commons==3.0.0'],
26
+ install_requires=['pytest', 'pytest-xdist', 'attrs', 'testit-python-commons==3.0.2'],
27
27
  entry_points={'pytest11': ['testit_adapter_pytest = testit_adapter_pytest.plugin']}
28
28
  )
@@ -128,8 +128,10 @@ class TmsListener(object):
128
128
  index = 0
129
129
 
130
130
  for item in items:
131
- if not hasattr(item.function, 'test_external_id'):
132
- item.function.test_external_id = utils.get_hash(item.parent.nodeid + item.function.__name__)
131
+ if hasattr(item.function, 'test_external_id'):
132
+ item.test_external_id = item.function.test_external_id
133
+ else:
134
+ item.test_external_id = utils.get_hash(item.parent.nodeid + item.function.__name__)
133
135
 
134
136
  if item.own_markers:
135
137
  for mark in item.own_markers:
@@ -140,8 +142,8 @@ class TmsListener(object):
140
142
  item.own_markers.index(mark))
141
143
 
142
144
  params = utils.get_all_parameters(item)
143
- item.function.test_external_id = utils.collect_parameters_in_string_attribute(
144
- item.function.test_external_id,
145
+ item.test_external_id = utils.collect_parameters_in_string_attribute(
146
+ item.test_external_id,
145
147
  params)
146
148
 
147
149
  item.index = index
@@ -149,7 +151,7 @@ class TmsListener(object):
149
151
  index = index + 1 if len(items) > item_id + 1 and items[item_id + 1].originalname == item.originalname \
150
152
  else 0
151
153
 
152
- if cls.__check_external_id_in_resolved_autotests(item.function.test_external_id, resolved_autotests):
154
+ if cls.__check_external_id_in_resolved_autotests(item.test_external_id, resolved_autotests):
153
155
  separation_of_tests.add_item_to_selected_items(item)
154
156
  else:
155
157
  separation_of_tests.add_item_to_deselected_items(item)
@@ -205,12 +207,6 @@ class TmsListener(object):
205
207
  name = f'{fixture_name}::{finalizer_name}'
206
208
  finalizers[index] = FixtureContext(finalizer, parent_uuid=container_uuid, name=name)
207
209
 
208
- if self.__executable_test:
209
- results_steps_data = self.__step_manager.get_steps_tree()
210
-
211
- if fixturedef.scope == 'function':
212
- self.__executable_test['setUpResults'] += results_steps_data
213
-
214
210
  @pytest.hookimpl(hookwrapper=True, trylast=True)
215
211
  def pytest_runtest_call(self):
216
212
  yield
@@ -219,18 +215,13 @@ class TmsListener(object):
219
215
  return
220
216
 
221
217
  test_results_steps = self.__step_manager.get_steps_tree()
222
- self.__executable_test['stepResults'] = test_results_steps
218
+ self.__executable_test.step_results = test_results_steps
223
219
 
224
220
  @pytest.hookimpl(hookwrapper=True)
225
221
  def pytest_fixture_post_finalizer(self, fixturedef):
226
222
  if not self.__executable_test:
227
223
  return
228
224
 
229
- teardown_results_steps = self.__step_manager.get_steps_tree()
230
-
231
- if fixturedef.scope == 'function':
232
- self.__executable_test['tearDownResults'] += teardown_results_steps
233
-
234
225
  yield
235
226
 
236
227
  if hasattr(fixturedef, 'cached_result') and self._cache.get(fixturedef):
@@ -241,28 +232,28 @@ class TmsListener(object):
241
232
  def pytest_runtest_logreport(self, report):
242
233
  if self.__executable_test:
243
234
  if report.when == 'setup':
244
- self.__executable_test['outcome'] = STATUS.get(report.outcome, None)
235
+ self.__executable_test.outcome = STATUS.get(report.outcome, None)
245
236
  if report.longreprtext:
246
- self.__executable_test['message'] = report.longreprtext
237
+ self.__executable_test.message = report.longreprtext
247
238
 
248
239
  if report.when == 'call':
249
- self.__executable_test['outcome'] = STATUS.get(report.outcome, None)
240
+ self.__executable_test.outcome = STATUS.get(report.outcome, None)
250
241
 
251
242
  if report.failed or hasattr(report, 'wasxfail') \
252
243
  and not report.passed or report.outcome == 'rerun':
253
- self.__executable_test['outcome'] = STATUS.get('failed', None)
244
+ self.__executable_test.outcome = STATUS.get('failed', None)
254
245
 
255
246
  if report.longreprtext:
256
- self.__executable_test['traces'] = report.longreprtext
247
+ self.__executable_test.traces = report.longreprtext
257
248
 
258
- self.__executable_test['duration'] += report.duration * 1000
249
+ self.__executable_test.duration += report.duration * 1000
259
250
 
260
251
  @pytest.hookimpl
261
252
  def pytest_runtest_logfinish(self):
262
253
  if not self.__executable_test:
263
254
  return
264
255
 
265
- self.__test_result_ids[self.__executable_test['externalID']] = self.__adapter_manager.write_test(
256
+ self.__test_result_ids[self.__executable_test.node_id] = self.__adapter_manager.write_test(
266
257
  utils.convert_executable_test_to_test_result_model(self.__executable_test))
267
258
 
268
259
  @pytest.hookimpl
@@ -279,22 +270,22 @@ class TmsListener(object):
279
270
  @adapter.hookimpl
280
271
  def add_link(self, link):
281
272
  if self.__executable_test:
282
- self.__executable_test['resultLinks'].append(link)
273
+ self.__executable_test.result_links.append(link)
283
274
 
284
275
  @adapter.hookimpl
285
276
  def add_message(self, test_message):
286
277
  if self.__executable_test:
287
- self.__executable_test['message'] = str(test_message)
278
+ self.__executable_test.message = str(test_message)
288
279
 
289
280
  @adapter.hookimpl
290
281
  def add_attachments(self, attach_paths: list or tuple):
291
282
  if self.__executable_test:
292
- self.__executable_test['attachments'] += self.__adapter_manager.load_attachments(attach_paths)
283
+ self.__executable_test.attachments += self.__adapter_manager.load_attachments(attach_paths)
293
284
 
294
285
  @adapter.hookimpl
295
286
  def create_attachment(self, body, name: str):
296
287
  if self.__executable_test:
297
- self.__executable_test['attachments'] += self.__adapter_manager.create_attachment(body, name)
288
+ self.__executable_test.attachments += self.__adapter_manager.create_attachment(body, name)
298
289
 
299
290
  @adapter.hookimpl
300
291
  def start_fixture(self, parent_uuid, uuid, title):
@@ -320,8 +311,8 @@ class TmsListener(object):
320
311
  group_uuid = self._cache.push(fixturedef)
321
312
  group = FixturesContainer(uuid=group_uuid)
322
313
  self.fixture_manager.start_group(group_uuid, group)
323
- if item.function.test_external_id not in group.external_ids:
324
- self.fixture_manager.update_group(group_uuid, external_ids=item.function.test_external_id)
314
+ if item.nodeid not in group.node_ids:
315
+ self.fixture_manager.update_group(group_uuid, node_ids=item.nodeid)
325
316
 
326
317
 
327
318
  def _test_fixtures(item):
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: testit-adapter-pytest
3
- Version: 3.0.0
3
+ Version: 3.0.2
4
4
  Summary: Pytest adapter for Test IT
5
5
  Home-page: https://github.com/testit-tms/adapters-python/
6
6
  Author: Integration team
@@ -18,7 +18,7 @@ Description-Content-Type: text/markdown
18
18
  Requires-Dist: pytest
19
19
  Requires-Dist: pytest-xdist
20
20
  Requires-Dist: attrs
21
- Requires-Dist: testit-python-commons==3.0.0
21
+ Requires-Dist: testit-python-commons==3.0.2
22
22
 
23
23
  # Test IT TMS adapter for Pytest
24
24
 
@@ -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.0.2
@@ -1,4 +0,0 @@
1
- pytest
2
- pytest-xdist
3
- attrs
4
- testit-python-commons==3.0.0