Lines Matching +full:self +full:- +full:test

17     def runtest(self):  argument
18 """Runs cleanup procedure for the test instead of the test itself"""
19 instance = self.parent.cls()
20 cleanup_name = "cleanup_{}".format(nodeid_to_method_name(self.nodeid))
23 cleanup(self.nodeid)
25 instance.cleanup(self.nodeid)
27 def setup_method_noop(self, method): argument
31 def teardown_method_noop(self, method): argument
37 def __init__(self, obj, has_cleanup): argument
38 # Use nodeid without name to properly name class-derived tests
39 self.ident = obj.nodeid.split("::", 1)[1]
40 self.description = self._get_test_description(obj)
41 self.has_cleanup = has_cleanup
42 self.obj = obj
44 def _get_test_description(self, obj): argument
45 """Returns first non-empty line from func docstring or func name"""
60 # First, require the unprivileged-user config option presence
76 def _convert_marks(self, obj) -> Dict[str, Any]: argument
79 "require_user": {"handler": self._convert_user_mark},
102 def as_lines(self) -> List[str]: argument
103 """Output test definition in ATF-specific format"""
105 ret.append("ident: {}".format(self.ident))
106 ret.append("descr: {}".format(self._get_test_description(self.obj)))
107 if self.has_cleanup:
109 for key, value in self._convert_marks(self.obj).items():
119 def __init__(self, report_file_name: Optional[str]): argument
120 self._tests_state_map: Dict[str, ReportStatus] = {}
121 self._report_file_name = report_file_name
122 self._report_file_handle = None
124 def setup_configure(self): argument
125 fname = self._report_file_name
127 self._report_file_handle = open(fname, mode="w")
129 def setup_method_pre(self, item): argument
130 """Called before actually running the test setup_method"""
134 cls = self.get_test_class(item)
138 def override_runtest(self, obj): argument
151 def has_object_cleanup(self, obj): argument
152 cls = self.get_test_class(obj)
160 def _generate_test_cleanups(self, items): argument
163 if self.has_object_cleanup(obj):
164 self.override_runtest(obj)
169 def expand_tests(self, collector, name, obj): argument
172 def modify_tests(self, items, config): argument
174 self._generate_test_cleanups(items)
176 def list_tests(self, tests: List[str]): argument
177 print('Content-Type: application/X-atf-tp; version="1"')
180 has_cleanup = self.has_object_cleanup(test_obj)
186 def set_report_state(self, test_name: str, state: str, reason: str): argument
187 self._tests_state_map[test_name] = self.ReportState(state, reason)
189 def _extract_report_reason(self, report): argument
194 # ('/path/to/test.py', 23, 'Skipped: unable to test')
202 return str(data).split("\n")[-1]
205 def add_report(self, report): argument
206 # MAP pytest report state to the atf-desired state
208 # ATF test states:
213 # Note that ATF don't have the concept of "soft xfail" - xpass
215 # process, thus teardown states (pytest-only) are handled as
220 # Just a passing test: WANT: passed
223 # Failing body test: WHAT: failed
226 # pytest.skip test decorator: WANT: skipped
229 # pytest.skip call inside test function: WANT: skipped
241 reason = self._extract_report_reason(report)
243 # We don't care about strict xfail - it gets translated to False
247 # failed init -> failed test, skipped setup -> xskip
248 # for the whole test
249 self.set_report_state(test_name, state, reason)
252 if test_name in self._tests_state_map:
253 if self._tests_state_map[test_name].state == "failed":
257 self.set_report_state(test_name, state, reason)
260 # xfail() called in the test body
265 self.set_report_state(test_name, state, reason)
268 # the test was expected to fail but didn't
271 self.set_report_state(test_name, state, reason)
278 self.set_report_state(test_name, state, reason)
280 def write_report(self): argument
281 if self._report_file_handle is None:
283 if self._tests_state_map:
284 # If we're executing in ATF mode, there has to be just one test
286 first_test_name = next(iter(self._tests_state_map))
287 test = self._tests_state_map[first_test_name]
288 if test.state == "passed":
289 line = test.state
291 line = "{}: {}".format(test.state, test.reason)
292 print(line, file=self._report_file_handle)
293 self._report_file_handle.close()
296 def get_atf_vars() -> Dict[str, str]: