• Inheritance setUp() and tearDown() methods from Classsetup() and Classteardown


     
    I have a general test class in my nosetests suit and some sub-classes, inheriting from it.

    The config is likewise:

    class CGeneral_Test(object)::
        """This class defines the general testcase"""
        def __init__ (self):
            do_some_init()
            print "initialisation of general class done!"
    
        def setUp(self):
            print "this is the general setup method"
            do_setup()
    
        def tearDown(self):
            print "this is the general teardown method"
            do_teardown()

    Now, I have the subclasses which looks like this:

    class CIPv6_Test(CGeneral_Test):
        """This class defines the sub, inherited testcase"""
        def __init__ (self):
            super(CIPv6_Test, self).__init__()
            do_some_sub_init()
            print "initialisation of sub class done!"
    
        def setUp(self):
            print "this is the per-test sub setup method"
            do_sub_setup()
    
        def test_routing_64(self):
            do_actual_testing_scenarios()
    
        def tearDown(self):
            print "this is the  per-test sub teardown method"
            do_sub_teardown()

    So, what I want to achieve would be that each test would invoke both the sub-class and the super class setUp methods. Hence, the desired order of test is:

    Base Setup
    Inherited Setup
    This is a some test.
    Inherited Teardown
    Base Teardown
  • 相关阅读:
    575. Distribute Candies
    242. Valid Anagram
    349. Intersection of Two Arrays
    290. Word Pattern
    389. Find the Difference
    httpModules 与 httpHandlers
    JS获取浏览器信息及屏幕分辨率
    asp.net 页面编码 设置的几种方法
    IIS是如何处理ASP.NET请求的
    VS2010常用插件介绍之Javascript插件(一)
  • 原文地址:https://www.cnblogs.com/Raul2018/p/10143747.html
Copyright © 2020-2023  润新知