How to use tearDown method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

testRemoveMembersFromGroups.py

Source:testRemoveMembersFromGroups.py Github

copy

Full Screen

...29 global testcase_id30 testcase_id = random_id()31 self.connection = get_connection()32 self.delete_at_teardown = []33 def tearDown(self):34 drop_connection(self.connection, self.delete_at_teardown)35 self.assertFalse(self.connection.bound)36 def test_remove_member_from_group(self):37 if test_server_type == 'EDIR' and not self.connection.strategy.pooled and not self.connection.strategy.no_real_dsa:38 self.delete_at_teardown.append(add_user(self.connection, testcase_id, 'user-1'))39 self.delete_at_teardown.append(add_group(self.connection, testcase_id, 'group-1'))40 self.delete_at_teardown.append(add_group(self.connection, testcase_id, 'group-1b', [self.delete_at_teardown[0]]))41 self.connection.extend.novell.add_members_to_groups(self.delete_at_teardown[0][0],42 [self.delete_at_teardown[1][0],43 self.delete_at_teardown[2][0]],44 fix=True,45 transaction=False)46 # verifies user in group-147 status, result, response, request = get_response_values(self.connection.search(self.delete_at_teardown[0][0], '(objectclass=*)', attributes=['securityEquals', 'groupMembership']), self.connection)...

Full Screen

Full Screen

test_suite.py

Source:test_suite.py Github

copy

Full Screen

...75 for klass in (MockTestCase, MockTestCaseSetup,76 MockTestCaseTeardown, MockTestCaseSetupTeardown):77 klass.reset()78 self.assertStateReset()79 def tearDown(self):80 for klass in (MockTestCase, MockTestCaseSetup,81 MockTestCaseTeardown, MockTestCaseSetupTeardown):82 klass.reset()83 self.assertStateReset()84 def assertStateReset(self):85 for klass in (MockTestCase, MockTestCaseSetup,86 MockTestCaseTeardown, MockTestCaseSetupTeardown):87 self.assertFalse(klass.setup)88 self.assertFalse(klass.teardown)89 self.assertFalse(klass.setup_raise)90 self.assertFalse(klass.teardown_raise)91 self.assertFalse(hasattr(klass, '__unittest_skip__'))92class TestTestSuiteState(ResetClassStateMixin, unittest.TestCase):93 def setUp(self):94 self.state = _TestSuiteState(ResultCollector())95 self._name_count = count(0)96 ResetClassStateMixin.setUp(self)97 def tearDown(self):98 ResetClassStateMixin.tearDown(self)99 del self.state100 def test_setup_none(self):101 self.assertTrue(self.state.setup(None))102 def test_teardown_no_prior_setup_does_not_raise(self):103 self.state.teardown()104 @contextmanager105 def _temporary_module(self, klass, module):106 module_name = 'haas_test_module_{0}'.format(next(self._name_count))107 self.assertNotIn(module_name, sys.modules)108 sys.modules[module_name] = module109 old_module = klass.__module__110 klass.__module__ = module_name111 try:112 yield113 finally:114 klass.__module__ = old_module115 del sys.modules[module_name]116 def _prepare_test(self, klass, module_factory, setup_raise,117 teardown_raise):118 klass.setup_raise = setup_raise119 klass.teardown_raise = teardown_raise120 test = klass()121 if module_factory is not None:122 module = module_factory(123 setup_raise=setup_raise,124 teardown_raise=teardown_raise,125 )126 else:127 module = None128 return test, module129 @contextmanager130 def _run_test_context(self, klass, module_factory, setup_raise,131 teardown_raise, class_setup, class_teardown,132 module_setup, module_teardown):133 test, module = self._prepare_test(134 klass, module_factory, setup_raise, teardown_raise)135 with self._temporary_module(klass, module):136 self.assertEqual(self.state.setup(test), not setup_raise)137 self.assertEqual(klass.setup, class_setup)138 self.assertFalse(klass.teardown)139 if module is not None:140 self.assertEqual(module.setup, module_setup)141 self.assertFalse(module.teardown)142 yield test143 self.state.teardown()144 self.assertEqual(klass.setup, class_setup)145 self.assertEqual(klass.teardown, class_teardown)146 if module is not None:147 self.assertEqual(module.setup, module_setup)148 self.assertEqual(module.teardown, module_teardown)149 def _run_test(self, klass, module_factory, setup_raise, teardown_raise,150 class_setup, class_teardown, module_setup, module_teardown):151 with self._run_test_context(152 klass, module_factory, setup_raise, teardown_raise,153 class_setup, class_teardown, module_setup, module_teardown):154 pass155 def test_call_setup_without_setup_or_teardown(self):156 self._run_test(157 klass=MockTestCase,158 module_factory=MockModule,159 setup_raise=False,160 teardown_raise=False,161 class_setup=False,162 class_teardown=False,163 module_setup=False,164 module_teardown=False,165 )166 def test_setup_skip(self):167 MockTestCaseSetupTeardown.__unittest_skip__ = True168 self._run_test(169 klass=MockTestCaseSetupTeardown,170 module_factory=MockModule,171 setup_raise=False,172 teardown_raise=False,173 class_setup=False,174 class_teardown=False,175 module_setup=False,176 module_teardown=False,177 )178 def test_setup_case_setup(self):179 self._run_test(180 klass=MockTestCaseSetup,181 module_factory=MockModule,182 setup_raise=False,183 teardown_raise=False,184 class_setup=True,185 class_teardown=False,186 module_setup=False,187 module_teardown=False,188 )189 def test_setup_case_teardown(self):190 self._run_test(191 klass=MockTestCaseTeardown,192 module_factory=MockModule,193 setup_raise=False,194 teardown_raise=False,195 class_setup=False,196 class_teardown=True,197 module_setup=False,198 module_teardown=False,199 )200 def test_setup_case_setup_and_teardown(self):201 self._run_test(202 klass=MockTestCaseSetupTeardown,203 module_factory=MockModule,204 setup_raise=False,205 teardown_raise=False,206 class_setup=True,207 class_teardown=True,208 module_setup=False,209 module_teardown=False,210 )211 def test_setup_case_setup_raises_and_teardown(self):212 self._run_test(213 klass=MockTestCaseSetupTeardown,214 module_factory=MockModule,215 setup_raise=True,216 teardown_raise=False,217 class_setup=True,218 class_teardown=False,219 module_setup=False,220 module_teardown=False,221 )222 def test_setup_case_setup_and_teardown_raises(self):223 self._run_test(224 klass=MockTestCaseSetupTeardown,225 module_factory=MockModule,226 setup_raise=False,227 teardown_raise=True,228 class_setup=True,229 class_teardown=True,230 module_setup=False,231 module_teardown=False,232 )233 def test_setup_module_setup(self):234 self._run_test(235 klass=MockTestCase,236 module_factory=MockModuleSetup,237 setup_raise=False,238 teardown_raise=False,239 class_setup=False,240 class_teardown=False,241 module_setup=True,242 module_teardown=False,243 )244 def test_setup_module_teardown(self):245 self._run_test(246 klass=MockTestCase,247 module_factory=MockModuleTeardown,248 setup_raise=False,249 teardown_raise=False,250 class_setup=False,251 class_teardown=False,252 module_setup=False,253 module_teardown=True,254 )255 def test_setup_module_setup_and_teardown(self):256 self._run_test(257 klass=MockTestCase,258 module_factory=MockModuleSetupTeardown,259 setup_raise=False,260 teardown_raise=False,261 class_setup=False,262 class_teardown=False,263 module_setup=True,264 module_teardown=True,265 )266 def test_setup_module_setup_raises_and_teardown(self):267 self._run_test(268 klass=MockTestCase,269 module_factory=MockModuleSetupTeardown,270 setup_raise=True,271 teardown_raise=False,272 class_setup=False,273 class_teardown=False,274 module_setup=True,275 module_teardown=False,276 )277 def test_setup_module_setup_and_teardown_raises(self):278 self._run_test(279 klass=MockTestCase,280 module_factory=MockModuleSetupTeardown,281 setup_raise=False,282 teardown_raise=True,283 class_setup=False,284 class_teardown=False,285 module_setup=True,286 module_teardown=True,287 )288 def test_setup_module_none(self):289 self._run_test(290 klass=MockTestCase,291 module_factory=None,292 setup_raise=False,293 teardown_raise=False,294 class_setup=False,295 class_teardown=False,296 module_setup=False,297 module_teardown=False,298 )299 def test_multiple_setup_teardown_different_class_module(self):300 with self._run_test_context(301 klass=MockTestCaseSetupTeardown,302 module_factory=MockModuleSetupTeardown,303 setup_raise=False,304 teardown_raise=False,305 class_setup=True,306 class_teardown=True,307 module_setup=True,308 module_teardown=True):309 klass = MockTestCaseSetup310 module_factory = MockModuleSetup311 setup_raise = False312 teardown_raise = False313 test, module = self._prepare_test(314 klass=klass,315 module_factory=module_factory,316 setup_raise=setup_raise,317 teardown_raise=teardown_raise,318 )319 with self._temporary_module(klass, module):320 self.assertEqual(self.state.setup(test), not setup_raise)321 self.assertTrue(klass.setup)322 self.assertFalse(klass.teardown)323 self.assertTrue(module.setup)324 self.assertFalse(module.teardown)325 # Top-level tear down has occurred326 self.assertTrue(klass.setup)327 self.assertFalse(klass.teardown)328 self.assertTrue(module.setup)329 self.assertFalse(module.teardown)330 def test_multiple_setup_teardown_same_class_module(self):331 with self._run_test_context(332 klass=MockTestCaseSetupTeardown,333 module_factory=MockModuleSetupTeardown,334 setup_raise=False,335 teardown_raise=False,336 class_setup=True,337 class_teardown=True,338 module_setup=True,339 module_teardown=True) as first_test:340 klass = MockTestCaseSetupTeardown341 setup_raise = False342 teardown_raise = False343 test, _ = self._prepare_test(344 klass=klass,345 module_factory=None,346 setup_raise=setup_raise,347 teardown_raise=teardown_raise,348 )349 module_name = first_test.__class__.__module__350 module = sys.modules[module_name]351 self.assertEqual(self.state.setup(test), not setup_raise)352 self.assertTrue(klass.setup)353 self.assertFalse(klass.teardown)354 self.assertTrue(module.setup)355 self.assertFalse(module.teardown)356 # Top-level tear down has occurred357 self.assertTrue(klass.setup)358 self.assertTrue(klass.teardown)359 self.assertTrue(module.setup)360 self.assertTrue(module.teardown)361class TestTestSuiteCount(unittest.TestCase):362 def test_count_empty(self):363 suite = TestSuite()364 self.assertEqual(suite.countTestCases(), 0)365 def test_one_level(self):366 suite = TestSuite(tests=[TestCase('test_method'), TestSuite()])367 self.assertEqual(suite.countTestCases(), 1)368 def test_suite_not_included_in_count(self):369 suite = TestSuite(370 tests=[371 TestSuite(tests=[TestSuite(), TestSuite(), TestSuite()]),372 TestSuite(),373 TestSuite(),374 ],375 )376 self.assertEqual(suite.countTestCases(), 0)377 def test_cases_included_in_count(self):378 suite = TestSuite(379 tests=[380 TestSuite(381 tests=[382 TestCase('test_method'),383 TestSuite(),384 TestSuite(),385 ],386 ),387 TestCase('test_method'),388 TestSuite(),389 ],390 )391 self.assertEqual(suite.countTestCases(), 2)392class TestTestSuiteEquality(unittest.TestCase):393 def test_equal_to_itself_empty(self):394 suite = TestSuite()395 self.assertEqual(suite, suite)396 def test_not_equal_to_empty_list(self):397 suite = TestSuite()398 self.assertNotEqual(suite, [])399 def test_equal_to_itself_nested(self):400 suite = TestSuite(401 tests=[402 TestSuite(403 tests=[404 TestCase('test_method'),405 TestSuite(),406 TestSuite(),407 ],408 ),409 TestCase('test_method'),410 TestSuite(),411 ],412 )413 self.assertEqual(suite, suite)414 def test_equal_to_other_nested(self):415 suite = TestSuite(416 tests=[417 TestSuite(418 tests=[419 TestCase('test_method'),420 TestSuite(),421 TestSuite(),422 ],423 ),424 TestCase('test_method'),425 TestSuite(),426 ],427 )428 suite2 = TestSuite(429 tests=[430 TestSuite(431 tests=[432 TestCase('test_method'),433 TestSuite(),434 TestSuite(),435 ],436 ),437 TestCase('test_method'),438 TestSuite(),439 ],440 )441 self.assertEqual(suite, suite2)442class TestRunningTestSuite(ResetClassStateMixin, unittest.TestCase):443 def setUp(self):444 ResetClassStateMixin.setUp(self)445 self.case_1 = MockTestCaseSetupTeardown()446 self.case_2 = MockTestCase()447 self.suite = TestSuite(448 tests=[449 TestSuite(450 tests=[451 self.case_1,452 TestSuite(),453 TestSuite(),454 ],455 ),456 self.case_2,457 TestSuite(),458 ],459 )460 def tearDown(self):461 del self.suite462 del self.case_1463 del self.case_2464 ResetClassStateMixin.tearDown(self)465 def test_run_suite_run(self):466 result = ResultCollector()467 returned_result = self.suite.run(result)468 self.assertIs(result, returned_result)469 self.assertTrue(self.case_1.was_run)470 self.assertTrue(self.case_2.was_run)471 def test_run_suite_call(self):472 result = ResultCollector()473 returned_result = self.suite(result)474 self.assertIs(result, returned_result)475 self.assertTrue(self.case_1.was_run)476 self.assertTrue(self.case_2.was_run)477 def test_run_suite_setup_error(self):478 self.case_1.__class__.setup_raise = True...

Full Screen

Full Screen

test_file.py

Source:test_file.py Github

copy

Full Screen

1# This file is part of Exdir, the Experimental Directory Structure.2#3# Copyright 2017 Simen Tennøe4#5# License: MIT, see "LICENSE" file for the full license terms.6#7# This file contains code from h5py, a Python interface to the HDF5 library,8# licensed under a standard 3-clause BSD license9# with copyright Andrew Collette and contributors.10# See http://www.h5py.org and the "3rdparty/h5py-LICENSE" file for details.11import pytest12import os13import pathlib14from exdir.core import File, Group15from exdir.core.exdir_object import _create_object_directory, is_nonraw_object_directory, DATASET_TYPENAME, FILE_TYPENAME16import exdir.core.filename_validation as fv17import numpy as np18from conftest import remove19def test_file_init(setup_teardown_folder):20 no_exdir = setup_teardown_folder[0] / "no_exdir"21 f = File(no_exdir, mode="w")22 f.close()23 assert is_nonraw_object_directory(no_exdir.with_suffix(".exdir"))24 remove(setup_teardown_folder[1])25 f = File(setup_teardown_folder[1], mode="w")26 f.close()27 assert is_nonraw_object_directory(setup_teardown_folder[1])28 remove(setup_teardown_folder[1])29 f = File(setup_teardown_folder[1], mode="a")30 f.close()31 assert is_nonraw_object_directory(setup_teardown_folder[1])32 remove(setup_teardown_folder[1])33 f = File(setup_teardown_folder[1], mode="a")34 f.close()35 assert is_nonraw_object_directory(setup_teardown_folder[1])36 remove(setup_teardown_folder[1])37 setup_teardown_folder[1].mkdir(parents=True)38 with pytest.raises(FileExistsError):39 f = File(setup_teardown_folder[1], mode="w")40 remove(setup_teardown_folder[1])41 _create_object_directory(pathlib.Path(setup_teardown_folder[1]), DATASET_TYPENAME)42 with pytest.raises(FileExistsError):43 f = File(setup_teardown_folder[1], mode="w")44 remove(setup_teardown_folder[1])45 with pytest.raises(IOError):46 f = File(setup_teardown_folder[1], mode="r")47 with pytest.raises(IOError):48 f = File(setup_teardown_folder[1], mode="r+")49 _create_object_directory(pathlib.Path(setup_teardown_folder[1]), FILE_TYPENAME)50 with pytest.raises(FileExistsError):51 f = File(setup_teardown_folder[1], mode="w")52 remove(setup_teardown_folder[1])53 _create_object_directory(pathlib.Path(setup_teardown_folder[1]), FILE_TYPENAME)54 f = File(setup_teardown_folder[1], mode="w", allow_remove=True)55 remove(setup_teardown_folder[1])56 _create_object_directory(pathlib.Path(setup_teardown_folder[1]), FILE_TYPENAME)57 with pytest.raises(IOError):58 f = File(setup_teardown_folder[1], mode="w-")59 with pytest.raises(IOError):60 f = File(setup_teardown_folder[1], mode="x")61 with pytest.raises(ValueError):62 f = File(setup_teardown_folder[1], mode="not existing")63def test_create(setup_teardown_folder):64 """Mode 'w' opens file in overwrite mode."""65 f = File(setup_teardown_folder[1], 'w')66 assert f67 f.create_group('foo')68 f.close()69 f = File(setup_teardown_folder[1], 'w', allow_remove=True)70 assert 'foo' not in f71 f.close()72 with pytest.raises(FileExistsError):73 f = File(setup_teardown_folder[1], 'w')74def test_create_exclusive(setup_teardown_folder):75 """Mode 'w-' opens file in exclusive mode."""76 f = File(setup_teardown_folder[1], 'w-')77 assert f78 f.close()79 with pytest.raises(IOError):80 File(setup_teardown_folder[1], 'w-')81def test_append(setup_teardown_folder):82 """Mode 'a' opens file in append/readwrite mode, creating if necessary."""83 f = File(setup_teardown_folder[1], 'a')84 assert f85 f.create_group('foo')86 assert 'foo' in f87 f = File(setup_teardown_folder[1], 'a')88 assert 'foo' in f89 f.create_group('bar')90 assert 'bar' in f91def test_readonly(setup_teardown_folder):92 """Mode 'r' opens file in readonly mode."""93 f = File(setup_teardown_folder[1], 'w')94 f.close()95 # TODO comment in when close is implemented96 # assert not f97 f = File(setup_teardown_folder[1], 'r')98 assert f99 with pytest.raises(IOError):100 f.create_group('foo')101 f.create_dataset("bar", (2))102 f.close()103def test_readwrite(setup_teardown_folder):104 """Mode 'r+' opens existing file in readwrite mode."""105 f = File(setup_teardown_folder[1], 'w')106 f.create_group('foo')107 f.close()108 f = File(setup_teardown_folder[1], 'r+')109 assert 'foo' in f110 f.create_group('bar')111 assert 'bar' in f112 f.close()113def test_nonexistent_file(setup_teardown_folder):114 """Modes 'r' and 'r+' do not create files."""115 with pytest.raises(IOError):116 File(setup_teardown_folder[1], 'r')117 with pytest.raises(IOError):118 File(setup_teardown_folder[1], 'r+')119def test_invalid_mode(setup_teardown_folder):120 """Invalid modes raise ValueError."""121 with pytest.raises(ValueError):122 File(setup_teardown_folder[1], 'Error mode')123def test_file_close(setup_teardown_folder):124 """Closing a file."""125 f = File(setup_teardown_folder[1], mode="w")126 f.close()127def test_validate_name_thorough(setup_teardown_folder):128 """Test naming rule thorough."""129 f = File(setup_teardown_folder[0] / "test.exdir", validate_name=fv.thorough)130 f.close()131 with pytest.raises(FileExistsError):132 File(setup_teardown_folder[0] / "Test.exdir", validate_name=fv.thorough)133 with pytest.raises(NameError):134 File(setup_teardown_folder[0] / "tes#.exdir", validate_name=fv.thorough)135def test_validate_name_strict(setup_teardown_folder):136 """Test naming rule strict."""137 f = File(setup_teardown_folder[1], validate_name=fv.strict)138 f.close()139 with pytest.raises(NameError):140 File(setup_teardown_folder[1].with_suffix(".exdirA"), validate_name=fv.strict)141def test_validate_name_error(setup_teardown_folder):142 """Test naming rule with error."""143 with pytest.raises(ValueError):144 File(setup_teardown_folder[1], validate_name='Error rule')145def test_validate_name_none(setup_teardown_folder):146 """Test naming rule with error."""147 File(setup_teardown_folder[1].with_name("test&().exdir"), validate_name=fv.none)148def test_opening_with_different_validate_name(setup_teardown_folder):149 """Test opening with wrong naming rule."""150 f = File(setup_teardown_folder[1], "w", validate_name=fv.none)151 f.create_group("AAA")152 f.close()153 # TODO changing name validation should result in warning/error154 f = File(setup_teardown_folder[1], "a", validate_name=fv.thorough)155 with pytest.raises(FileExistsError):156 f.create_group("aaa")157 f.close()158def test_contains(setup_teardown_file):159 """Root group (by itself) is contained."""160 f = setup_teardown_file[3]161 f.create_group("test")162 assert "/" in f163 assert "/test" in f164def test_create_group(setup_teardown_file):165 """Root group (by itself) is contained."""166 f = setup_teardown_file[3]167 grp = f.create_group("/test")168 assert isinstance(grp, Group)169def test_require_group(setup_teardown_file):170 """Root group (by itself) is contained."""171 f = setup_teardown_file[3]172 grp = f.require_group("/foo")173 assert isinstance(grp, Group)174def test_open(setup_teardown_file):175 """thorough obj[name] opening."""176 f = setup_teardown_file[3]177 grp = f.create_group("foo")178 grp2 = f["foo"]179 grp3 = f["/foo"]180 f = f["/"]181 assert grp == grp2182 assert grp2 == grp3183 assert f == f184def test_open_mode(setup_teardown_folder):185 # must exist186 for mode in ["r+", "r"]:187 with pytest.raises(IOError):188 f = File(setup_teardown_folder[1], mode)189 # create if not exist190 for mode in ["a", "w", "w-"]:191 remove(setup_teardown_folder[1])192 f = File(setup_teardown_folder[1], mode)193 f.require_dataset('dset', np.arange(10))194 f.attrs['can_overwrite'] = 42195 f.attrs['can_overwrite'] = 14196 f.require_group('mygroup')197 remove(setup_teardown_folder[1])198 f = File(setup_teardown_folder[1], 'w')199 f.close() # dummy close200 # read write if exist201 f = File(setup_teardown_folder[1], "r+")202 f.require_group('mygroup')203 f.require_dataset('dset', np.arange(10))204 f.attrs['can_overwrite'] = 42205 f.attrs['can_overwrite'] = 14206 # read only, can not write207 f = File(setup_teardown_folder[1], 'r')208 with pytest.raises(IOError):209 f.require_dataset('dset', np.arange(10))210 f.attrs['can_not_write'] = 42211 f.create_group('mygroup')212def test_open_two_attrs(setup_teardown_file):213 f = setup_teardown_file[3]214 f.attrs['can_overwrite'] = 42215 f.attrs['another_atribute'] = 14216# TODO uncomment when enter and exit has been implemented217# # Feature: File objects can be used as context managers218# def test_context_manager(setup_teardown_folder):219# """File objects can be used in with statements."""220# no_exdir = pytest.TESTPATH / "no_exdir"221# with File(no_exdir, mode="w") as f:222# assert f...

Full Screen

Full Screen

test_statuses.py

Source:test_statuses.py Github

copy

Full Screen

...8 self.log.info('setup post')9 def test(self):10 self.log.info('test pre')11 self.log.info('test post')12 def tearDown(self):13 self.log.info('teardown pre')14 self.log.info('teardown status: %s', self.status)15 self.log.info('teardown post')16class SkipTest(Test):17 def setUp(self):18 self.log.info('setup pre')19 self.log.info('setup post')20 @skip("from test()")21 def test(self):22 self.log.info('test pre')23 self.log.info('test post')24 def tearDown(self):25 self.log.info('teardown pre')26 self.log.info('teardown status: %s', self.status)27 self.log.info('teardown post')28class SkipTeardown(Test):29 def setUp(self):30 self.log.info('setup pre')31 self.log.info('setup post')32 def test(self):33 self.log.info('test pre')34 self.log.info('test post')35 @skip("from tearDown()")36 def tearDown(self):37 self.log.info('teardown pre')38 self.log.info('teardown status: %s', self.status)39 self.log.info('teardown post')40class CancelSetup(Test):41 def setUp(self):42 self.log.info('setup pre')43 self.cancel()44 self.log.info('setup post')45 def test(self):46 self.log.info('test pre')47 self.log.info('test post')48 def tearDown(self):49 self.log.info('teardown pre')50 self.log.info('teardown status: %s', self.status)51 self.log.info('teardown post')52class CancelTest(Test):53 def setUp(self):54 self.log.info('setup pre')55 self.log.info('setup post')56 def test(self):57 self.log.info('test pre')58 self.cancel()59 self.log.info('test post')60 def tearDown(self):61 self.log.info('teardown pre')62 self.log.info('teardown status: %s', self.status)63 self.log.info('teardown post')64class CancelTeardown(Test):65 def setUp(self):66 self.log.info('setup pre')67 self.log.info('setup post')68 def test(self):69 self.log.info('test pre')70 self.log.info('test post')71 def tearDown(self):72 self.log.info('teardown pre')73 self.log.info('teardown status: %s', self.status)74 self.cancel()75 self.log.info('teardown post')76class FailSetup(Test):77 def setUp(self):78 self.log.info('setup pre')79 self.fail()80 self.log.info('setup post')81 def test(self):82 self.log.info('test pre')83 self.log.info('test post')84 def tearDown(self):85 self.log.info('teardown pre')86 self.log.info('teardown status: %s', self.status)87 self.log.info('teardown post')88class FailTest(Test):89 def setUp(self):90 self.log.info('setup pre')91 self.log.info('setup post')92 def test(self):93 self.log.info('test pre')94 self.fail()95 self.log.info('test post')96 def tearDown(self):97 self.log.info('teardown pre')98 self.log.info('teardown status: %s', self.status)99 self.log.info('teardown post')100class FailTeardown(Test):101 def setUp(self):102 self.log.info('setup pre')103 self.log.info('setup post')104 def test(self):105 self.log.info('test pre')106 self.log.info('test post')107 def tearDown(self):108 self.log.info('teardown pre')109 self.log.info('teardown status: %s', self.status)110 self.fail()111 self.log.info('teardown post')112class WarnSetup(Test):113 def setUp(self):114 self.log.info('setup pre')115 self.log.warn('')116 self.log.info('setup post')117 def test(self):118 self.log.info('test pre')119 self.log.info('test post')120 def tearDown(self):121 self.log.info('teardown pre')122 self.log.info('teardown status: %s', self.status)123 self.log.info('teardown post')124class WarnTest(Test):125 def setUp(self):126 self.log.info('setup pre')127 self.log.info('setup post')128 def test(self):129 self.log.info('test pre')130 self.log.warn('')131 self.log.info('test post')132 def tearDown(self):133 self.log.info('teardown pre')134 self.log.info('teardown status: %s', self.status)135 self.log.info('teardown post')136class WarnTeardown(Test):137 def setUp(self):138 self.log.info('setup pre')139 self.log.info('setup post')140 def test(self):141 self.log.info('test pre')142 self.log.info('test post')143 def tearDown(self):144 self.log.info('teardown pre')145 self.log.info('teardown status: %s', self.status)146 self.log.warn('')147 self.log.info('teardown post')148class ExitSetup(Test):149 def setUp(self):150 self.log.info('setup pre')151 sys.exit(-1)152 self.log.info('setup post')153 def test(self):154 self.log.info('test pre')155 self.log.info('test post')156 def tearDown(self):157 self.log.info('teardown pre')158 self.log.info('teardown status: %s', self.status)159 self.log.info('teardown post')160class ExitTest(Test):161 def setUp(self):162 self.log.info('setup pre')163 self.log.info('setup post')164 def test(self):165 self.log.info('test pre')166 sys.exit(-1)167 self.log.info('test post')168 def tearDown(self):169 self.log.info('teardown pre')170 self.log.info('teardown status: %s', self.status)171 self.log.info('teardown post')172class ExitTeardown(Test):173 def setUp(self):174 self.log.info('setup pre')175 self.log.info('setup post')176 def test(self):177 self.log.info('test pre')178 self.log.info('test post')179 def tearDown(self):180 self.log.info('teardown pre')181 self.log.info('teardown status: %s', self.status)182 sys.exit(-1)183 self.log.info('teardown post')184class ExceptionSetup(Test):185 def setUp(self):186 self.log.info('setup pre')187 raise ValueError188 # pylint: disable=W0101189 self.log.info('setup post')190 def test(self):191 self.log.info('test pre')192 self.log.info('test post')193 def tearDown(self):194 self.log.info('teardown pre')195 self.log.info('teardown status: %s', self.status)196 self.log.info('teardown post')197class ExceptionTest(Test):198 def setUp(self):199 self.log.info('setup pre')200 self.log.info('setup post')201 def test(self):202 self.log.info('test pre')203 raise ValueError204 # pylint: disable=W0101205 self.log.info('test post')206 def tearDown(self):207 self.log.info('teardown pre')208 self.log.info('teardown status: %s', self.status)209 self.log.info('teardown post')210class ExceptionTeardown(Test):211 def setUp(self):212 self.log.info('setup pre')213 self.log.info('setup post')214 def test(self):215 self.log.info('test pre')216 self.log.info('test post')217 def tearDown(self):218 self.log.info('teardown pre')219 self.log.info('teardown status: %s', self.status)220 raise ValueError221 # pylint: disable=W0101222 self.log.info('teardown post')223class KillTest(Test):224 def setUp(self):225 self.log.info('setup pre')226 self.log.info('setup post')227 def test(self):228 self.log.info('test pre')229 os.kill(os.getpid(), 9)230 self.log.info('test post')231 def tearDown(self):232 self.log.info('teardown pre')233 self.log.info('teardown status: %s', self.status)...

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 robotframework-appiumlibrary 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