How to use test_teardown method in selenium-respectful

Best Python code snippet using selenium-respectful_python

model.py

Source:model.py Github

copy

Full Screen

1#!/usr/bin/env python2# encoding: utf-83"""4@version: 2.75@author: 'john'6@time: 2017/10/16 下午10:257@contact: zhouqiang847@gmail.com8"""9from robot.variables import GLOBAL_VARIABLES10from robot import utils11from robot.parsing.model import TestSuiteData12from robot.common.model import BaseTestSuite13from robot.common.model import BaseTestCase14from robot.running.keywords import KeywordFactory15def TestSuite(datasources, settings, syslog):16 """生成可运行的测试套件"""17 suitedata = TestSuiteData(datasources, settings, syslog)18 suite = RunnableTestSuite(suitedata)19 return suite20class RunnableTestSuite(BaseTestSuite):21 """表示可运行的测试套件"""22 def __init__(self, suitedata, parentdatas=[]):23 parentdatas = parentdatas[:] + [suitedata]24 super(RunnableTestSuite, self).__init__(suitedata.name, suitedata.source)25 self.variables = GLOBAL_VARIABLES.copy()26 self.variables.set_from_variable_table(suitedata.variables)27 self.doc = suitedata.doc is not None and suitedata.doc or ''28 self.setup = utils.get_not_none(suitedata.suite_setup, [])29 self.teardown = utils.get_not_none(suitedata.suite_teardown, [])30 self.suites = [RunnableTestSuite(suite, parentdatas)31 for suite in suitedata.suites]32 self.tests = [RunnableTestCase(test, parentdatas)33 for test in suitedata.tests]34class RunnableTestCase(BaseTestCase):35 """表示可运行的测试用例"""36 def __init__(self, testdata, parentdatas):37 """初始化38 测试用例的setup会覆盖所属测试套件的test_setup39 测试用例的teardown会覆盖所属测试套件的test_teardown40 测试用例的timeout会覆盖所属测试套件的test_timeout41 测试用例的tags等于所属测试套件的force_tags + 测试用例自己的tags42 """43 BaseTestCase.__init__(self, testdata.name)44 self.doc = testdata.doc is not None and testdata.doc or ''45 test_setup, test_teardown, force_tags, default_tags, test_timeout \46 = self._proces_parents(parentdatas)47 self.setup = utils.get_not_none(testdata.setup, test_setup, [])48 self.teardown = utils.get_not_none(testdata.teardown, test_teardown, [])49 self.tags = force_tags + utils.get_not_none(testdata.tags, default_tags, [])50 self.timeout = utils.get_not_none(testdata.timeout, test_timeout, [])51 self.keywords = [KeywordFactory(kw) for kw in testdata.keywords]52 self.message = ''53 def _proces_parents(self, parentdatas):54 """获取所属测试套件的`test_setup`、`test_teardown`等属性"""55 test_setup = test_teardown = default_tags = test_timeout = None56 force_tags = []57 parentdatas.reverse()58 for parent in parentdatas:59 if parent.test_setup is not None and test_setup is None:60 test_setup = parent.test_setup61 if parent.test_teardown is not None and test_teardown is None:62 test_teardown = parent.test_teardown63 if parent.force_tags is not None:64 force_tags.extend(parent.force_tags)65 if parent.default_tags is not None and default_tags is None:66 default_tags = parent.default_tags67 if parent.test_timeout is not None and test_timeout is None:68 test_timeout = parent.test_timeout69 return test_setup, test_teardown, force_tags, default_tags, test_timeout70# todo:最后删除掉71if __name__ == '__main__':72 from robot.output.systemLogger import SystemLogger...

Full Screen

Full Screen

test_layers_simple.py

Source:test_layers_simple.py Github

copy

Full Screen

1import unittest2class Layer1(object):3 layer_setup = 04 test_setup = 05 test_teardown = 06 layer_teardown = 07 tests_count = 08 @classmethod9 def setUp(cls):10 if cls.layer_setup >= 1:11 raise Exception("layer_setup already ran")12 cls.layer_setup += 113 @classmethod14 def testSetUp(cls):15 if cls.test_setup >= 2:16 raise Exception("test_setup already ran twice")17 cls.test_setup += 118 @classmethod19 def testTearDown(cls):20 if cls.test_teardown >= 2:21 raise Exception("test_teardown already ran twice")22 cls.test_teardown += 123 @classmethod24 def tearDown(cls):25 if cls.layer_teardown >= 1:26 raise Exception("layer_teardown already ran")27 cls.layer_teardown += 128class TestSimple(unittest.TestCase):29 layer = Layer130 def test_1(self):31 assert self.layer.layer_setup == 132 assert self.layer.test_setup == self.layer.tests_count + 133 assert self.layer.test_teardown == self.layer.tests_count34 assert self.layer.layer_teardown == 035 self.layer.tests_count += 136 def test_2(self):37 assert self.layer.layer_setup == 138 assert self.layer.test_setup == self.layer.tests_count + 139 assert self.layer.test_teardown == self.layer.tests_count40 assert self.layer.layer_teardown == 0...

Full Screen

Full Screen

urls.py

Source:urls.py Github

copy

Full Screen

1from django.urls import path2from . import views3urlpatterns = [4 path('user', views.user, name='user'),5 path('superuser', views.superuser, name='superuser'),6 path('topic', views.topic, name='topic'),7 path('test_setup', views.test_setup, name='test_setup'),8 path('test_teardown', views.test_teardown, name='test_teardown'),...

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 selenium-respectful 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