testit-adapter-pytest 2.8.2__tar.gz → 3.0.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 (20) hide show
  1. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/PKG-INFO +2 -2
  2. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/setup.py +2 -2
  3. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest/listener.py +53 -45
  4. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest/utils.py +1 -1
  5. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest.egg-info/PKG-INFO +2 -2
  6. testit_adapter_pytest-3.0.0/src/testit_adapter_pytest.egg-info/requires.txt +4 -0
  7. testit-adapter-pytest-2.8.2/src/testit_adapter_pytest.egg-info/requires.txt +0 -4
  8. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/README.md +0 -0
  9. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/setup.cfg +0 -0
  10. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest/__init__.py +0 -0
  11. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest/fixture_context.py +0 -0
  12. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest/fixture_manager.py +0 -0
  13. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest/fixture_storage.py +0 -0
  14. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest/models/__init__.py +0 -0
  15. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest/models/fixture.py +0 -0
  16. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest/plugin.py +0 -0
  17. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest.egg-info/SOURCES.txt +0 -0
  18. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest.egg-info/dependency_links.txt +0 -0
  19. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.0}/src/testit_adapter_pytest.egg-info/entry_points.txt +0 -0
  20. {testit-adapter-pytest-2.8.2 → testit_adapter_pytest-3.0.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: 2.8.2
3
+ Version: 3.0.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
@@ -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==2.8.2
21
+ Requires-Dist: testit-python-commons==3.0.0
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='2.8.2',
5
+ version='3.0.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",
@@ -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==2.8.2'],
26
+ install_requires=['pytest', 'pytest-xdist', 'attrs', 'testit-python-commons==3.0.0'],
27
27
  entry_points={'pytest11': ['testit_adapter_pytest = testit_adapter_pytest.plugin']}
28
28
  )
@@ -23,6 +23,42 @@ STATUS = {
23
23
  }
24
24
 
25
25
 
26
+ class ItemCache:
27
+ def __init__(self):
28
+ self._items = dict()
29
+
30
+ def get(self, _id):
31
+ return self._items.get(id(_id))
32
+
33
+ def push(self, _id):
34
+ return self._items.setdefault(id(_id), uuid4())
35
+
36
+ def pop(self, _id):
37
+ return self._items.pop(id(_id), None)
38
+
39
+
40
+ class SeparationOfTests:
41
+ def __init__(self):
42
+ self._selected_items = []
43
+ self._deselected_items = []
44
+
45
+ def add_item_to_selected_items(self, item):
46
+ self._selected_items.append(item)
47
+
48
+ return self
49
+
50
+ def add_item_to_deselected_items(self, item):
51
+ self._deselected_items.append(item)
52
+
53
+ return self
54
+
55
+ def get_selected_items(self) -> list:
56
+ return self._selected_items
57
+
58
+ def get_deselected_items(self) -> list:
59
+ return self._deselected_items
60
+
61
+
26
62
  class TmsListener(object):
27
63
  __executable_test = None
28
64
  __pytest_check_info = None
@@ -68,17 +104,16 @@ class TmsListener(object):
68
104
  def pytest_collection_modifyitems(self, config, items):
69
105
  self.__add_pytest_check_info(config.pluginmanager.list_plugin_distinfo())
70
106
 
71
- deselected_items = []
72
107
  resolved_autotests = self.__adapter_manager.get_autotests_for_launch()
73
- selected_items = self.__get_selected_items(items, resolved_autotests)
108
+ separation_of_tests = self.__get_separation_of_tests(items, resolved_autotests)
74
109
 
75
110
  if resolved_autotests:
76
- if not selected_items:
111
+ if not separation_of_tests.get_selected_items():
77
112
  print('The specified tests were not found!')
78
113
  raise SystemExit
79
114
 
80
- config.hook.pytest_deselected(items=deselected_items)
81
- items[:] = selected_items
115
+ config.hook.pytest_deselected(items=separation_of_tests.get_deselected_items())
116
+ items[:] = separation_of_tests.get_selected_items()
82
117
 
83
118
  def __add_pytest_check_info(self, plugin_info):
84
119
  for plugin, dist in plugin_info:
@@ -88,15 +123,13 @@ class TmsListener(object):
88
123
 
89
124
  @classmethod
90
125
  @adapter_logger
91
- def __get_selected_items(cls, items, resolved_autotests) -> list:
92
- selected_items = []
126
+ def __get_separation_of_tests(cls, items, resolved_autotests) -> SeparationOfTests:
127
+ separation_of_tests = SeparationOfTests()
93
128
  index = 0
94
129
 
95
130
  for item in items:
96
- if hasattr(item.function, 'test_external_id'):
97
- item.test_external_id = item.function.test_external_id
98
- else:
99
- item.test_external_id = utils.get_hash(item.nodeid + item.function.__name__)
131
+ if not hasattr(item.function, 'test_external_id'):
132
+ item.function.test_external_id = utils.get_hash(item.parent.nodeid + item.function.__name__)
100
133
 
101
134
  if item.own_markers:
102
135
  for mark in item.own_markers:
@@ -107,8 +140,8 @@ class TmsListener(object):
107
140
  item.own_markers.index(mark))
108
141
 
109
142
  params = utils.get_all_parameters(item)
110
- item.test_external_id = utils.collect_parameters_in_string_attribute(
111
- item.test_external_id,
143
+ item.function.test_external_id = utils.collect_parameters_in_string_attribute(
144
+ item.function.test_external_id,
112
145
  params)
113
146
 
114
147
  item.index = index
@@ -116,10 +149,12 @@ class TmsListener(object):
116
149
  index = index + 1 if len(items) > item_id + 1 and items[item_id + 1].originalname == item.originalname \
117
150
  else 0
118
151
 
119
- if cls.__check_external_id_in_resolved_autotests(item.test_external_id, resolved_autotests):
120
- selected_items.append(item)
152
+ if cls.__check_external_id_in_resolved_autotests(item.function.test_external_id, resolved_autotests):
153
+ separation_of_tests.add_item_to_selected_items(item)
154
+ else:
155
+ separation_of_tests.add_item_to_deselected_items(item)
121
156
 
122
- return selected_items
157
+ return separation_of_tests
123
158
 
124
159
  @staticmethod
125
160
  @adapter_logger
@@ -128,19 +163,6 @@ class TmsListener(object):
128
163
 
129
164
  @pytest.hookimpl(tryfirst=True)
130
165
  def pytest_runtest_protocol(self, item):
131
- if not hasattr(item.function, 'test_external_id'):
132
- item.test_external_id = utils.get_hash(item.nodeid + item.function.__name__)
133
-
134
- if not hasattr(item.function, 'test_displayname'):
135
- item.test_displayname = item.function.__doc__ if \
136
- item.function.__doc__ else item.function.__name__
137
- else:
138
- params = utils.get_all_parameters(item)
139
-
140
- item.test_displayname = utils.collect_parameters_in_string_attribute(
141
- item.function.test_displayname,
142
- params)
143
-
144
166
  self.__executable_test = utils.form_test(item)
145
167
 
146
168
  @pytest.hookimpl(hookwrapper=True)
@@ -298,22 +320,8 @@ class TmsListener(object):
298
320
  group_uuid = self._cache.push(fixturedef)
299
321
  group = FixturesContainer(uuid=group_uuid)
300
322
  self.fixture_manager.start_group(group_uuid, group)
301
- if item.test_external_id not in group.external_ids:
302
- self.fixture_manager.update_group(group_uuid, external_ids=item.test_external_id)
303
-
304
-
305
- class ItemCache:
306
- def __init__(self):
307
- self._items = dict()
308
-
309
- def get(self, _id):
310
- return self._items.get(id(_id))
311
-
312
- def push(self, _id):
313
- return self._items.setdefault(id(_id), uuid4())
314
-
315
- def pop(self, _id):
316
- return self._items.pop(id(_id), None)
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)
317
325
 
318
326
 
319
327
  def _test_fixtures(item):
@@ -75,7 +75,7 @@ def __get_external_id_from(item):
75
75
  external_id = __search_attribute(item, 'test_external_id')
76
76
 
77
77
  if not external_id:
78
- return get_hash(item.nodeid + item.function.__name__)
78
+ return get_hash(item.parent.nodeid + item.function.__name__)
79
79
 
80
80
  return collect_parameters_in_string_attribute(external_id, get_all_parameters(item))
81
81
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: testit-adapter-pytest
3
- Version: 2.8.2
3
+ Version: 3.0.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
@@ -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==2.8.2
21
+ Requires-Dist: testit-python-commons==3.0.0
22
22
 
23
23
  # Test IT TMS adapter for Pytest
24
24
 
@@ -0,0 +1,4 @@
1
+ pytest
2
+ pytest-xdist
3
+ attrs
4
+ testit-python-commons==3.0.0
@@ -1,4 +0,0 @@
1
- pytest
2
- pytest-xdist
3
- attrs
4
- testit-python-commons==2.8.2