How to use assert_last method in avocado

Best Python code snippet using avocado_python

taptests.py

Source:taptests.py Github

copy

Full Screen

...27 def assert_error(self, events):28 self.assertEqual(type(next(events)), TAPParser.Error)29 def assert_bailout(self, events, **kwargs):30 self.assertEqual(next(events), TAPParser.Bailout(**kwargs))31 def assert_last(self, events):32 with self.assertRaises(StopIteration):33 next(events)34 def parse_tap(self, s):35 parser = TAPParser()36 return iter(parser.parse(io.StringIO(s)))37 def parse_tap_v13(self, s):38 events = self.parse_tap('TAP version 13\n' + s)39 self.assert_version(events, version=13)40 return events41 def test_empty(self):42 events = self.parse_tap('')43 self.assert_last(events)44 def test_empty_plan(self):45 events = self.parse_tap('1..0')46 self.assert_plan(events, num_tests=0, late=False, skipped=True)47 self.assert_last(events)48 def test_plan_directive(self):49 events = self.parse_tap('1..0 # skipped for some reason')50 self.assert_plan(events, num_tests=0, late=False, skipped=True,51 explanation='for some reason')52 self.assert_last(events)53 events = self.parse_tap('1..1 # skipped for some reason\nok 1')54 self.assert_error(events)55 self.assert_plan(events, num_tests=1, late=False, skipped=True,56 explanation='for some reason')57 self.assert_test(events, number=1, name='', result=TestResult.OK)58 self.assert_last(events)59 events = self.parse_tap('1..1 # todo not supported here\nok 1')60 self.assert_error(events)61 self.assert_plan(events, num_tests=1, late=False, skipped=False,62 explanation='not supported here')63 self.assert_test(events, number=1, name='', result=TestResult.OK)64 self.assert_last(events)65 def test_one_test_ok(self):66 events = self.parse_tap('ok')67 self.assert_test(events, number=1, name='', result=TestResult.OK)68 self.assert_last(events)69 def test_one_test_with_number(self):70 events = self.parse_tap('ok 1')71 self.assert_test(events, number=1, name='', result=TestResult.OK)72 self.assert_last(events)73 def test_one_test_with_name(self):74 events = self.parse_tap('ok 1 abc')75 self.assert_test(events, number=1, name='abc', result=TestResult.OK)76 self.assert_last(events)77 def test_one_test_not_ok(self):78 events = self.parse_tap('not ok')79 self.assert_test(events, number=1, name='', result=TestResult.FAIL)80 self.assert_last(events)81 def test_one_test_todo(self):82 events = self.parse_tap('not ok 1 abc # TODO')83 self.assert_test(events, number=1, name='abc', result=TestResult.EXPECTEDFAIL)84 self.assert_last(events)85 events = self.parse_tap('ok 1 abc # TODO')86 self.assert_test(events, number=1, name='abc', result=TestResult.UNEXPECTEDPASS)87 self.assert_last(events)88 def test_one_test_skip(self):89 events = self.parse_tap('ok 1 abc # SKIP')90 self.assert_test(events, number=1, name='abc', result=TestResult.SKIP)91 self.assert_last(events)92 def test_one_test_skip_failure(self):93 events = self.parse_tap('not ok 1 abc # SKIP')94 self.assert_test(events, number=1, name='abc', result=TestResult.FAIL)95 self.assert_last(events)96 def test_many_early_plan(self):97 events = self.parse_tap('1..4\nok 1\nnot ok 2\nok 3\nnot ok 4')98 self.assert_plan(events, num_tests=4, late=False)99 self.assert_test(events, number=1, name='', result=TestResult.OK)100 self.assert_test(events, number=2, name='', result=TestResult.FAIL)101 self.assert_test(events, number=3, name='', result=TestResult.OK)102 self.assert_test(events, number=4, name='', result=TestResult.FAIL)103 self.assert_last(events)104 def test_many_late_plan(self):105 events = self.parse_tap('ok 1\nnot ok 2\nok 3\nnot ok 4\n1..4')106 self.assert_test(events, number=1, name='', result=TestResult.OK)107 self.assert_test(events, number=2, name='', result=TestResult.FAIL)108 self.assert_test(events, number=3, name='', result=TestResult.OK)109 self.assert_test(events, number=4, name='', result=TestResult.FAIL)110 self.assert_plan(events, num_tests=4, late=True)111 self.assert_last(events)112 def test_directive_case(self):113 events = self.parse_tap('ok 1 abc # skip')114 self.assert_test(events, number=1, name='abc', result=TestResult.SKIP)115 self.assert_last(events)116 events = self.parse_tap('ok 1 abc # ToDo')117 self.assert_test(events, number=1, name='abc', result=TestResult.UNEXPECTEDPASS)118 self.assert_last(events)119 def test_directive_explanation(self):120 events = self.parse_tap('ok 1 abc # skip why')121 self.assert_test(events, number=1, name='abc', result=TestResult.SKIP,122 explanation='why')123 self.assert_last(events)124 events = self.parse_tap('ok 1 abc # ToDo Because')125 self.assert_test(events, number=1, name='abc', result=TestResult.UNEXPECTEDPASS,126 explanation='Because')127 self.assert_last(events)128 def test_one_test_early_plan(self):129 events = self.parse_tap('1..1\nok')130 self.assert_plan(events, num_tests=1, late=False)131 self.assert_test(events, number=1, name='', result=TestResult.OK)132 self.assert_last(events)133 def test_one_test_late_plan(self):134 events = self.parse_tap('ok\n1..1')135 self.assert_test(events, number=1, name='', result=TestResult.OK)136 self.assert_plan(events, num_tests=1, late=True)137 self.assert_last(events)138 def test_out_of_order(self):139 events = self.parse_tap('ok 2')140 self.assert_error(events)141 self.assert_test(events, number=2, name='', result=TestResult.OK)142 self.assert_last(events)143 def test_middle_plan(self):144 events = self.parse_tap('ok 1\n1..2\nok 2')145 self.assert_test(events, number=1, name='', result=TestResult.OK)146 self.assert_plan(events, num_tests=2, late=True)147 self.assert_error(events)148 self.assert_test(events, number=2, name='', result=TestResult.OK)149 self.assert_last(events)150 def test_too_many_plans(self):151 events = self.parse_tap('1..1\n1..2\nok 1')152 self.assert_plan(events, num_tests=1, late=False)153 self.assert_error(events)154 self.assert_test(events, number=1, name='', result=TestResult.OK)155 self.assert_last(events)156 def test_too_many(self):157 events = self.parse_tap('ok 1\nnot ok 2\n1..1')158 self.assert_test(events, number=1, name='', result=TestResult.OK)159 self.assert_test(events, number=2, name='', result=TestResult.FAIL)160 self.assert_plan(events, num_tests=1, late=True)161 self.assert_error(events)162 self.assert_last(events)163 events = self.parse_tap('1..1\nok 1\nnot ok 2')164 self.assert_plan(events, num_tests=1, late=False)165 self.assert_test(events, number=1, name='', result=TestResult.OK)166 self.assert_test(events, number=2, name='', result=TestResult.FAIL)167 self.assert_error(events)168 self.assert_last(events)169 def test_too_few(self):170 events = self.parse_tap('ok 1\nnot ok 2\n1..3')171 self.assert_test(events, number=1, name='', result=TestResult.OK)172 self.assert_test(events, number=2, name='', result=TestResult.FAIL)173 self.assert_plan(events, num_tests=3, late=True)174 self.assert_error(events)175 self.assert_last(events)176 events = self.parse_tap('1..3\nok 1\nnot ok 2')177 self.assert_plan(events, num_tests=3, late=False)178 self.assert_test(events, number=1, name='', result=TestResult.OK)179 self.assert_test(events, number=2, name='', result=TestResult.FAIL)180 self.assert_error(events)181 self.assert_last(events)182 def test_too_few_bailout(self):183 events = self.parse_tap('1..3\nok 1\nnot ok 2\nBail out! no third test')184 self.assert_plan(events, num_tests=3, late=False)185 self.assert_test(events, number=1, name='', result=TestResult.OK)186 self.assert_test(events, number=2, name='', result=TestResult.FAIL)187 self.assert_bailout(events, message='no third test')188 self.assert_last(events)189 def test_diagnostics(self):190 events = self.parse_tap('1..1\n# ignored\nok 1')191 self.assert_plan(events, num_tests=1, late=False)192 self.assert_test(events, number=1, name='', result=TestResult.OK)193 self.assert_last(events)194 events = self.parse_tap('# ignored\n1..1\nok 1\n# ignored too')195 self.assert_plan(events, num_tests=1, late=False)196 self.assert_test(events, number=1, name='', result=TestResult.OK)197 self.assert_last(events)198 events = self.parse_tap('# ignored\nok 1\n1..1\n# ignored too')199 self.assert_test(events, number=1, name='', result=TestResult.OK)200 self.assert_plan(events, num_tests=1, late=True)201 self.assert_last(events)202 def test_empty_line(self):203 events = self.parse_tap('1..1\n\nok 1')204 self.assert_plan(events, num_tests=1, late=False)205 self.assert_test(events, number=1, name='', result=TestResult.OK)206 self.assert_last(events)207 def test_unexpected(self):208 events = self.parse_tap('1..1\ninvalid\nok 1')209 self.assert_plan(events, num_tests=1, late=False)210 self.assert_test(events, number=1, name='', result=TestResult.OK)211 self.assert_last(events)212 def test_version(self):213 events = self.parse_tap('TAP version 13\n')214 self.assert_version(events, version=13)215 self.assert_last(events)216 events = self.parse_tap('TAP version 12\n')217 self.assert_error(events)218 self.assert_last(events)219 events = self.parse_tap('1..0\nTAP version 13\n')220 self.assert_plan(events, num_tests=0, late=False, skipped=True)221 self.assert_error(events)222 self.assert_last(events)223 def test_yaml(self):224 events = self.parse_tap_v13('ok\n ---\n foo: abc\n bar: def\n ...\nok 2')225 self.assert_test(events, number=1, name='', result=TestResult.OK)226 self.assert_test(events, number=2, name='', result=TestResult.OK)227 self.assert_last(events)228 events = self.parse_tap_v13('ok\n ---\n foo: abc\n bar: def')229 self.assert_test(events, number=1, name='', result=TestResult.OK)230 self.assert_error(events)231 self.assert_last(events)232 events = self.parse_tap_v13('ok 1\n ---\n foo: abc\n bar: def\nnot ok 2')233 self.assert_test(events, number=1, name='', result=TestResult.OK)234 self.assert_error(events)235 self.assert_test(events, number=2, name='', result=TestResult.FAIL)...

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