testit-adapter-nose 3.3.0__tar.gz → 3.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: testit-adapter-nose
3
- Version: 3.3.0
3
+ Version: 3.3.2
4
4
  Summary: Nose adapter for Test IT
5
5
  Home-page: https://github.com/testit-tms/adapters-python/
6
6
  Author: Integration team
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.12
17
17
  Description-Content-Type: text/markdown
18
18
  Requires-Dist: attrs
19
19
  Requires-Dist: nose2
20
- Requires-Dist: testit-python-commons==3.3.0
20
+ Requires-Dist: testit-python-commons==3.3.2
21
21
 
22
22
  # Test IT TMS adapter for Nose
23
23
 
@@ -87,6 +87,21 @@ $ nose2 --testit
87
87
  If you want to enable debug mode then
88
88
  see [How to enable debug logging?](https://github.com/testit-tms/adapters-python/tree/main/testit-python-commons)
89
89
 
90
+ #### Run with filter
91
+ To create filter by autotests you can use the Test IT CLI (use adapterMode 1 for run with filter):
92
+
93
+ ```
94
+ $ export TMS_TOKEN=<YOUR_TOKEN>
95
+ $ testit autotests_filter
96
+ --url https://tms.testit.software \
97
+ --configuration-id 5236eb3f-7c05-46f9-a609-dc0278896464 \
98
+ --testrun-id 6d4ac4b7-dd67-4805-b879-18da0b89d4a8 \
99
+ --framework nose \
100
+ --output tmp/filter.txt
101
+
102
+ $ nose2 $(cat tmp/filter.txt) --testit
103
+ ```
104
+
90
105
  ### Decorators
91
106
 
92
107
  Decorators can be used to specify information about autotest.
@@ -66,6 +66,21 @@ $ nose2 --testit
66
66
  If you want to enable debug mode then
67
67
  see [How to enable debug logging?](https://github.com/testit-tms/adapters-python/tree/main/testit-python-commons)
68
68
 
69
+ #### Run with filter
70
+ To create filter by autotests you can use the Test IT CLI (use adapterMode 1 for run with filter):
71
+
72
+ ```
73
+ $ export TMS_TOKEN=<YOUR_TOKEN>
74
+ $ testit autotests_filter
75
+ --url https://tms.testit.software \
76
+ --configuration-id 5236eb3f-7c05-46f9-a609-dc0278896464 \
77
+ --testrun-id 6d4ac4b7-dd67-4805-b879-18da0b89d4a8 \
78
+ --framework nose \
79
+ --output tmp/filter.txt
80
+
81
+ $ nose2 $(cat tmp/filter.txt) --testit
82
+ ```
83
+
69
84
  ### Decorators
70
85
 
71
86
  Decorators can be used to specify information about autotest.
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='testit-adapter-nose',
5
- version='3.3.0',
5
+ version='3.3.2',
6
6
  description='Nose adapter for Test IT',
7
7
  long_description=open('README.md', "r").read(),
8
8
  long_description_content_type="text/markdown",
@@ -23,7 +23,7 @@ setup(
23
23
  py_modules=['testit_adapter_nose'],
24
24
  packages=find_packages(where='src'),
25
25
  package_dir={'': 'src'},
26
- install_requires=['attrs', 'nose2', 'testit-python-commons==3.3.0'],
26
+ install_requires=['attrs', 'nose2', 'testit-python-commons==3.3.2'],
27
27
  entry_points={
28
28
  'nose.plugins.0.10': [
29
29
  'testit_adapter_nose = testit_adapter_nose.plugin:TmsPlugin',
@@ -12,9 +12,10 @@ from .utils import (
12
12
  class AdapterListener(object):
13
13
  __executable_test = None
14
14
 
15
- def __init__(self, adapter_manager: AdapterManager, step_manager: StepManager):
15
+ def __init__(self, adapter_manager: AdapterManager, step_manager: StepManager, top_level_directory: str):
16
16
  self.__adapter_manager = adapter_manager
17
17
  self.__step_manager = step_manager
18
+ self.__top_level_directory = top_level_directory
18
19
 
19
20
  def start_launch(self):
20
21
  test_run_id = self.__adapter_manager.get_test_run_id()
@@ -25,7 +26,7 @@ class AdapterListener(object):
25
26
  return self.__adapter_manager.get_autotests_for_launch()
26
27
 
27
28
  def start_test(self, test):
28
- self.__executable_test = form_test(test)
29
+ self.__executable_test = form_test(test, self.__top_level_directory)
29
30
 
30
31
  def set_outcome(self, event):
31
32
  outcome, message, trace = get_outcome(event)
@@ -10,14 +10,20 @@ class TmsPlugin(Plugin):
10
10
  commandLineSwitch = (None, 'testit', 'TMS adapter for Nose')
11
11
  __listener = None
12
12
  __tests_for_launch = None
13
+ __top_level_directory = None
13
14
 
14
15
  def __init__(self, *args, **kwargs):
15
16
  super(TmsPlugin, self).__init__(*args, **kwargs)
16
17
 
18
+ def handleDir(self, event):
19
+ if not self.__top_level_directory:
20
+ self.__top_level_directory = event.topLevelDirectory
21
+
17
22
  def startTestRun(self, event):
18
23
  self.__listener = AdapterListener(
19
24
  TmsPluginManager.get_adapter_manager(),
20
- TmsPluginManager.get_step_manager())
25
+ TmsPluginManager.get_step_manager(),
26
+ self.__top_level_directory)
21
27
 
22
28
  TmsPluginManager.get_plugin_manager().register(self.__listener)
23
29
 
@@ -1,6 +1,8 @@
1
1
  import hashlib
2
2
  import logging
3
3
  import re
4
+ import os
5
+ import typing
4
6
  from traceback import format_exception_only
5
7
  from nose2 import (
6
8
  util,
@@ -62,7 +64,7 @@ def get_outcome(event):
62
64
  return outcome, message, trace
63
65
 
64
66
 
65
- def form_test(item):
67
+ def form_test(item, top_level_directory):
66
68
  data = {}
67
69
 
68
70
  if hasattr(item, "_testFunc"):
@@ -90,7 +92,8 @@ def form_test(item):
90
92
  'links': __get_links_from(item),
91
93
  'labels': __get_labels_from(item),
92
94
  'workItemsID': __get_work_item_ids_from(item),
93
- 'message': None
95
+ 'message': None,
96
+ 'externalKey': __get_fullname(item, top_level_directory)
94
97
  }
95
98
 
96
99
  elif hasattr(item, "_testMethodName"):
@@ -258,6 +261,37 @@ def __get_work_item_ids_from(item):
258
261
  return map(str, result) if isinstance(result, __ARRAY_TYPES) else [str(result)]
259
262
 
260
263
 
264
+ def __get_fullname(item, top_level_directory: str):
265
+ test_function = item._testFunc
266
+ module_file_name = __get_module_file_name_by_test_function(test_function)
267
+
268
+ if not module_file_name:
269
+ return __join_nose_test_node([test_function.__module__, test_function.__qualname__])
270
+
271
+ absolute_module_path = __get_absolute_module_path_by_file_name(module_file_name)
272
+ module_node = __convert_absolute_module_path_to_nose_module_node(absolute_module_path, top_level_directory)
273
+
274
+ return __join_nose_test_node([module_node, test_function.__module__, test_function.__qualname__])
275
+
276
+
277
+ def __get_module_file_name_by_test_function(test_function):
278
+ return __import__(test_function.__module__).__file__
279
+
280
+
281
+ def __get_absolute_module_path_by_file_name(module_file_name: str):
282
+ return os.path.dirname(module_file_name)
283
+
284
+
285
+ def __convert_absolute_module_path_to_nose_module_node(absolute_module_path: str, top_level_directory: str):
286
+ directories_in_project = absolute_module_path.replace(top_level_directory + os.sep, '')
287
+
288
+ return directories_in_project.replace(os.sep, '.')
289
+
290
+
291
+ def __join_nose_test_node(test_node_parts: typing.List[str]):
292
+ return ".".join(test_node_parts)
293
+
294
+
261
295
  def fullname(event):
262
296
  if hasattr(event.test, "_testFunc"):
263
297
  test_module = event.test._testFunc.__module__
@@ -379,4 +413,5 @@ def convert_executable_test_to_test_result_model(executable_test: dict) -> TestR
379
413
  .set_result_links(executable_test['resultLinks'])\
380
414
  .set_labels(executable_test['labels'])\
381
415
  .set_work_item_ids(executable_test['workItemsID'])\
382
- .set_message(executable_test['message'])
416
+ .set_message(executable_test['message'])\
417
+ .set_external_key(executable_test['externalKey'])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: testit-adapter-nose
3
- Version: 3.3.0
3
+ Version: 3.3.2
4
4
  Summary: Nose adapter for Test IT
5
5
  Home-page: https://github.com/testit-tms/adapters-python/
6
6
  Author: Integration team
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.12
17
17
  Description-Content-Type: text/markdown
18
18
  Requires-Dist: attrs
19
19
  Requires-Dist: nose2
20
- Requires-Dist: testit-python-commons==3.3.0
20
+ Requires-Dist: testit-python-commons==3.3.2
21
21
 
22
22
  # Test IT TMS adapter for Nose
23
23
 
@@ -87,6 +87,21 @@ $ nose2 --testit
87
87
  If you want to enable debug mode then
88
88
  see [How to enable debug logging?](https://github.com/testit-tms/adapters-python/tree/main/testit-python-commons)
89
89
 
90
+ #### Run with filter
91
+ To create filter by autotests you can use the Test IT CLI (use adapterMode 1 for run with filter):
92
+
93
+ ```
94
+ $ export TMS_TOKEN=<YOUR_TOKEN>
95
+ $ testit autotests_filter
96
+ --url https://tms.testit.software \
97
+ --configuration-id 5236eb3f-7c05-46f9-a609-dc0278896464 \
98
+ --testrun-id 6d4ac4b7-dd67-4805-b879-18da0b89d4a8 \
99
+ --framework nose \
100
+ --output tmp/filter.txt
101
+
102
+ $ nose2 $(cat tmp/filter.txt) --testit
103
+ ```
104
+
90
105
  ### Decorators
91
106
 
92
107
  Decorators can be used to specify information about autotest.
@@ -0,0 +1,3 @@
1
+ attrs
2
+ nose2
3
+ testit-python-commons==3.3.2
@@ -1,3 +0,0 @@
1
- attrs
2
- nose2
3
- testit-python-commons==3.3.0