Best Python code snippet using slash
result.py
Source:result.py
...176 """177 err = self._add_error(self._failures, e, frame_correction=frame_correction + 1, exc_info=exc_info, is_failure=True, append=append)178 context.reporter.report_test_failure_added(context.test, err)179 return err180 def set_test_detail(self, key, value):181 """Adds a generic detail to this test result, which can be later inspected or used182 """183 self.details.set(key, value)184 def _add_error(self, error_list, error=None, frame_correction=0, exc_info=None, is_failure=False, append=True):185 try:186 if error is None:187 error = Error.capture_exception(exc_info=exc_info)188 if error is None:189 raise RuntimeError('add_error() must be called with either an argument or in an active exception')190 if not isinstance(error, Error):191 error = Error(error, frame_correction=frame_correction + 1, exc_info=exc_info)192 if is_failure:193 # force the error object to be marked as failure194 error.mark_as_failure()...
test_xunit_plugin.py
Source:test_xunit_plugin.py
...17 summary = suite.run(expect_session_errors=True)18 assert 'ZeroDivision' in summary.get_console_output()19def test_xunit_plugin_test_details(suite, suite_test, xunit_filename, details):20 for key, value in details.items():21 suite_test.append_line('slash.context.result.set_test_detail({!r}, {!r})'.format(key, value))22 suite.run()23 testcase_xml = _get_testcase_xml(suite_test, xunit_filename)24 saved_details = {}25 for d in testcase_xml.findall('detail'):26 k = d.attrib['name']27 if 'value' in d.attrib:28 v = d.attrib['value']29 else:30 v = [child for child in d]31 saved_details[k] = v32 assert saved_details33@pytest.mark.parametrize('errtype', ['error', 'failure'])34def test_xunit_plugin_add_failure_error(suite, suite_test, xunit_filename, errtype):35 num_errors = 3...
__init__.py
Source:__init__.py
...46 the amount of frames to skip to reach the actual cause of the added failure47 """48 if context.session is not None:49 return context.session.results.current.add_failure(msg, frame_correction=frame_correction+1, exc_info=exc_info)50def set_test_detail(key, value):51 """52 Store an object providing additional information about the current running test in a certain key.53 Each test has its own storage.54 :param key: a hashable object55 :param value: can be either an object or a string representing additional details56 """57 if context.session is not None:...
test_result_details.py
Source:test_result_details.py
1import pytest2def test_set_test_detail(result):3 result.set_test_detail('x', 'y')4 assert result.details.all() == {'x': 'y'}5def test_set(result):6 result.details.set('x', 'y')7 assert result.details.all() == {'x': 'y'}8def test_append(result):9 result.details.append('x', 'y')10 assert result.details.all() == {'x': ['y']}11def test_append_invalid_type(result):12 result.details.set('x', 'y')13 with pytest.raises(TypeError):14 result.details.append('x', 'y')15 assert result.details.all() == {'x': 'y'}16def test_bool(result):17 assert not result.details...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!