robotcode-modifiers 0.82.0__tar.gz → 0.82.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.3
2
2
  Name: robotcode-modifiers
3
- Version: 0.82.0
3
+ Version: 0.82.2
4
4
  Summary: Some Robot Framework Modifiers for RobotCode
5
5
  Project-URL: Homepage, https://robotcode.io
6
6
  Project-URL: Donate, https://opencollective.com/robotcode
@@ -0,0 +1 @@
1
+ __version__ = "0.82.2"
@@ -0,0 +1,61 @@
1
+ from typing import Optional, Union
2
+
3
+ from robot.api import SuiteVisitor
4
+ from robot.running import TestCase, TestSuite
5
+
6
+
7
+ class _BaseSuiteVisitor(SuiteVisitor):
8
+ def __init__(self, *included: str, root_name: Optional[str] = None) -> None:
9
+ super().__init__()
10
+ self.included = list(included)
11
+
12
+ self.root_name = root_name
13
+ self.real_root_name: Optional[str] = None
14
+
15
+ def start_suite(self, suite: TestSuite) -> None:
16
+ if self.real_root_name is None and self.root_name is not None:
17
+ self.real_root_name = suite.longname
18
+ new_included = []
19
+ for i in self.included:
20
+ if "." in i:
21
+ root_name, rest = c if len(c := i.split(".", 1)) > 1 else (c, None)
22
+ if root_name == self.root_name:
23
+ if rest is not None:
24
+ new_included.append(f"{self.real_root_name}.{rest}")
25
+ else:
26
+ new_included.append(f"{self.real_root_name}'")
27
+ else:
28
+ new_included.append(i)
29
+ else:
30
+ new_included.append(i)
31
+ self.included = new_included
32
+
33
+ def _is_included(self, test: Union[TestCase, TestSuite]) -> bool:
34
+ names = []
35
+ names.append(test.longname)
36
+ current = test.parent
37
+ while current:
38
+ if current.parent is None:
39
+ names.append(self.root_name if self.root_name is not None else current.longname)
40
+ else:
41
+ names.append(current.longname)
42
+ current = current.parent
43
+
44
+ return any((s in names) for s in self.included)
45
+
46
+ def end_suite(self, suite: TestSuite) -> None:
47
+ suite.suites = [s for s in suite.suites if s.test_count > 0]
48
+
49
+
50
+ class ByLongName(_BaseSuiteVisitor):
51
+ def start_suite(self, suite: TestSuite) -> None:
52
+ super().start_suite(suite)
53
+
54
+ suite.tests = [t for t in suite.tests if self._is_included(t)]
55
+
56
+
57
+ class ExcludedByLongName(_BaseSuiteVisitor):
58
+ def start_suite(self, suite: TestSuite) -> None:
59
+ super().start_suite(suite)
60
+
61
+ suite.tests = [t for t in suite.tests if not self._is_included(t)]
@@ -1 +0,0 @@
1
- __version__ = "0.82.0"
@@ -1,48 +0,0 @@
1
- from typing import Union
2
-
3
- from robot.api import SuiteVisitor
4
- from robot.running import TestCase, TestSuite
5
-
6
-
7
- class ByLongName(SuiteVisitor):
8
- def __init__(self, *included: str) -> None:
9
- super().__init__()
10
- self.included = included
11
-
12
- def start_suite(self, suite: TestSuite) -> None:
13
- suite.tests = [t for t in suite.tests if self._is_included(t)]
14
-
15
- def _is_included(self, test: Union[TestCase, TestSuite]) -> bool:
16
- names = []
17
- names.append(test.longname)
18
- current = test.parent
19
- while current:
20
- names.append(current.longname)
21
- current = current.parent
22
-
23
- return any((s in names) for s in self.included)
24
-
25
- def end_suite(self, suite: TestSuite) -> None:
26
- suite.suites = [s for s in suite.suites if s.test_count > 0]
27
-
28
-
29
- class ExcludedByLongName(SuiteVisitor):
30
- def __init__(self, *included: str) -> None:
31
- super().__init__()
32
- self.included = included
33
-
34
- def start_suite(self, suite: TestSuite) -> None:
35
- suite.tests = [t for t in suite.tests if not self._is_included(t)]
36
-
37
- def _is_included(self, test: Union[TestCase, TestSuite]) -> bool:
38
- names = []
39
- names.append(test.longname)
40
- current = test.parent
41
- while current:
42
- names.append(current.longname)
43
- current = current.parent
44
-
45
- return any((s in names) for s in self.included)
46
-
47
- def end_suite(self, suite: TestSuite) -> None:
48
- suite.suites = [s for s in suite.suites if s.test_count > 0]