Following this answer of this thread, I'm trying to override super class init function of testing project with python unittest that has three classes as below:
base.py
import unittest
class BaseTest(unittest.TestCase):
def setUp(self):
print '\n\t Prepare configuration'
#: executed after each test
def tearDown(self):
print '\n\t Closing session'
helper.py
from base import *
class HELPER(BaseTest):
""" Predefine Parameter """
URL = ''
ID = ''
Module = ''
def __init__(self, module=''):
self.Module = module
def open_url(self):
print "INIT FROM SUPER CLASS IS "
print self.Module
status_code = 200
self.assertEqual(200,status_code)
test_province.py
from helper import *
class TestProvince(HELPER):
def __init__(self, module = ''):
super(TestProvince, self).__init__()
self.Module = 'Province'
def test_open_url(self):
self.open_url()
if __name__ == "__main__":
unittest.main()
The detail is that in test_province.py
that I tried to override super class HELPER
's init function but it does not work with an error execption
AttributeError: 'TestProvince' object has no attribute '_testMethodName'
What is wrong or missing with this? How can I override super class init function correctly? Please kindly help Thanks