How to use _test_skip_helper method in tempest

Best Python code snippet using tempest_python

test_decorators.py

Source:test_decorators.py Github

copy

Full Screen

...57 condition=True)58@six.add_metaclass(abc.ABCMeta)59class BaseSkipDecoratorTests(object):60 @abc.abstractmethod61 def _test_skip_helper(self, raise_exception=True, expected_to_skip=True,62 **decorator_args):63 return64 def test_skip_launchpad_bug(self):65 self._test_skip_helper(bug='12345')66 def test_skip_storyboard_bug(self):67 self._test_skip_helper(bug='1992', bug_type='storyboard')68 def test_skip_bug_without_bug_never_skips(self):69 """Never skip without a bug parameter."""70 self._test_skip_helper(71 raise_exception=False, expected_to_skip=False, condition=True)72 self._test_skip_helper(73 raise_exception=False, expected_to_skip=False)74 def test_skip_invalid_bug_number(self):75 """Raise InvalidParam if with an invalid bug number"""76 self.assertRaises(lib_exc.InvalidParam, self._test_skip_helper,77 bug='critical_bug')78class TestSkipBecauseDecorator(base.TestCase, BaseSkipDecoratorTests):79 def _test_skip_helper(self, raise_exception=True, expected_to_skip=True,80 **decorator_args):81 class TestFoo(test.BaseTestCase):82 _interface = 'json'83 @decorators.skip_because(**decorator_args)84 def test_bar(self):85 return 086 t = TestFoo('test_bar')87 if expected_to_skip:88 e = self.assertRaises(testtools.TestCase.skipException, t.test_bar)89 bug = decorator_args['bug']90 bug_type = decorator_args.get('bug_type', 'launchpad')91 self.assertRegex(92 str(e),93 r'Skipped until bug\: %s.*' % decorators._get_bug_url(94 bug, bug_type)95 )96 else:97 # assert that test_bar returned 098 self.assertEqual(TestFoo('test_bar').test_bar(), 0)99 def test_skip_because_launchpad_bug_and_condition_true(self):100 self._test_skip_helper(bug='12348', condition=True)101 def test_skip_because_launchpad_bug_and_condition_false(self):102 self._test_skip_helper(expected_to_skip=False,103 bug='12349', condition=False)104 def test_skip_because_storyboard_bug_and_condition_false(self):105 self._test_skip_helper(expected_to_skip=False,106 bug='1992', bug_type='storyboard',107 condition=False)108 def test_skip_because_storyboard_bug_and_condition_true(self):109 self._test_skip_helper(bug='1992', bug_type='storyboard',110 condition=True)111class TestUnstableTestDecorator(base.TestCase, BaseSkipDecoratorTests):112 def _test_skip_helper(self, raise_exception=True, expected_to_skip=True,113 **decorator_args):114 fail_test_reason = "test_bar failed"115 class TestFoo(test.BaseTestCase):116 @decorators.unstable_test(**decorator_args)117 def test_bar(self):118 if raise_exception:119 raise Exception(fail_test_reason)120 else:121 return 0122 t = TestFoo('test_bar')123 if expected_to_skip:124 e = self.assertRaises(testtools.TestCase.skipException, t.test_bar)125 bug = decorator_args['bug']126 bug_type = decorator_args.get('bug_type', 'launchpad')127 self.assertRegex(128 str(e),129 r'Marked as unstable and skipped because of bug\: %s.*, '130 'failure was: %s' % (decorators._get_bug_url(bug, bug_type),131 fail_test_reason)132 )133 else:134 # assert that test_bar returned 0135 self.assertEqual(TestFoo('test_bar').test_bar(), 0)136 def test_skip_bug_given_exception_not_raised(self):137 self._test_skip_helper(raise_exception=False, expected_to_skip=False,138 bug='1234')139class TestIdempotentIdDecorator(base.TestCase):140 def _test_helper(self, _id, **decorator_args):141 @decorators.idempotent_id(_id)142 def foo():143 """Docstring"""144 pass145 return foo146 def _test_helper_without_doc(self, _id, **decorator_args):147 @decorators.idempotent_id(_id)148 def foo():149 pass150 return foo151 def test_positive(self):...

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 tempest 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