How to use mark_exception_fatal method in Slash

Best Python code snippet using slash

test_exception_handling.py

Source:test_exception_handling.py Github

copy

Full Screen

...14@pytest.mark.parametrize('context', [None, 'Something'])15def test_handling_exceptions_log(context, is_fatal):16 raised = CustomException()17 if is_fatal:18 exception_handling.mark_exception_fatal(raised)19 with slash.Session():20 with logbook.TestHandler() as handler:21 with exception_handling.handling_exceptions(context=context, swallow=True):22 raise raised23 assert len(handler.records) == 324 assert handler.records[1].message.startswith('Error added')25 assert handler.records[2].message.startswith('Swallowing')26 handle_exc_msg = handler.records[0].message27 assert handle_exc_msg.startswith('Handling exception')28 if context:29 assert 'Context: {}'.format(context) in handle_exc_msg30 else:31 assert 'Context' not in handle_exc_msg32 if is_fatal:...

Full Screen

Full Screen

exception_handling.py

Source:exception_handling.py Github

copy

Full Screen

...150 and returns it151 """152 mark_exception(exception, "swallow", False)153 return exception154def mark_exception_fatal(exception):155 """156 Causes this exception to halt the execution of the entire run.157 This is useful when detecting errors that need careful examination, thus preventing further tests from158 altering the test subject's state159 """160 mark_exception(exception, "fatal", True)161 return exception162def mark_exception_frame_correction(exception, correction=+1):163 current_correction = get_exception_frame_correction(exception)164 return mark_exception(exception, 'frame_correction', current_correction + correction)165def get_exception_frame_correction(exception):166 return get_exception_mark(exception, 'frame_correction', 0)167def is_exception_fatal(exception):168 return bool(get_exception_mark(exception, "fatal", False))...

Full Screen

Full Screen

test_cleanups.py

Source:test_cleanups.py Github

copy

Full Screen

...55 def __code__():56 @slash.add_cleanup57 def cleanup():58 from slash.exception_handling import mark_exception_fatal59 raise mark_exception_fatal(Exception())60 suite_test.expect_error()61 for t in suite.iter_all_after(suite_test, assert_has_more=not is_last_test):62 t.expect_not_run()63 suite.run()64def test_add_skip_from_test_cleanup(suite, suite_test):65 cleanup = suite_test.add_deferred_event(decorator='slash.add_cleanup', extra_code=['slash.skip_test()'])66 suite_test.expect_skip()67 summary = suite.run()68 assert summary.events[cleanup].timestamp69@pytest.mark.parametrize('cleanup_mechanism', ['this', 'slash'])70def test_add_skip_from_fixture_cleanup(suite, suite_test, cleanup_mechanism):71 suite_test.expect_skip()72 fixture = suite.slashconf.add_fixture()73 suite_test.depend_on_fixture(fixture)...

Full Screen

Full Screen

test_running.py

Source:test_running.py Github

copy

Full Screen

...109 def adder(test):110 if request.param == 'raising':111 test.append_line(112 'from slash.exception_handling import mark_exception_fatal')113 test.append_line('raise mark_exception_fatal({}())'.format('AssertionError' if failure_type == 'failure' else 'Exception'))114 elif request.param == 'adding':115 test.append_line('slash.add_{}("msg").mark_fatal()'.format(failure_type))116 else:117 raise NotImplementedError() # pragma: no cover118 getattr(test, 'expect_{}'.format(failure_type))()119 return adder120@pytest.fixture(params=['failure', 'error'])121def failure_type(request):...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful