I'm new to coding and Python. Not sure where exactly I should be looking to fix this error.

from UIMap  import tomcat8LoginPage,tomcat8urls,competitors

class test_Competitors(unittest):

def setup(self, driver):
    self.driver = driver
    self.driver = webdriver.Firefox()

def test_Compete(self):
    driver = self.driver
    actions = ActionChains(driver)

    ### Log-in and navigate to Competitors page ###
        (10, driver.find_element_by_id\
            (tomcat8LoginPage ['usernameField']),'username2092')

        (10, driver.find_element_by_id\

        (10, driver.find_element_by_id\
            (tomcat8LoginPage ['loginBtn']))

    driver.get(tomcat8urls ['newUIurl'])

    self. click\
        (10, driver.find_element_by_xpath\
            (competitors ['inboundMenu']))
  • self is also argument. BTW you need to forget your annoying \ at the end of the line. Parens work just fine over multiple lines, and \ will break if someone adds a whitespace after it. Using \ for line continuation is very much against best practices in Python Feb 14 '15 at 1:01
  • I mean self.method(a, b) has 3 arguments: self, a, and b. Feb 14 '15 at 1:03

I am not sure if i know how you got your error. But i have faced this error lot of times and to me looks like its the same. I don't have enough reputation to comment and ask but still would like to answer it.

Problem in your code:

You are trying to inherit from unittest which is a MODULE and not a CLASS.

For example :

>>> import unittest
>>> class A(unittest):
...     def A(self):
...        print("Something...")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)

This shows all the attributes of the module :

>>> dir(unittest)
['FunctionTestCase', 'TestCase', 'TestLoader', 'TestProgram', 'TestResult', 'TestSuite', 'TextTestRunner', '_CmpToKey', '_TextTestResult', '_WritelnDecorator', '__all__', '__author__', '__builtins__', '__doc__', '__email__', '__file__', '__metaclass__', '__name__', '__package__', '__unittest', '__version__', '_makeLoader', '_strclass', 'defaultTestLoader', 'findTestCases', 'getTestCaseNames', 'main', 'makeSuite', 'os', 'sys', 'time', 'traceback', 'types']

I guess you want to imherit a class like "TestCase" and not "unittest" itself.

Try help(unittest) in python inyterpreter and you will get to know a lot about unittest .

Here is a simple usage of unittest copied from the help :

class IntegerArithmenticTestCase(unittest.TestCase):
    def testAdd(self):  ## test method names begin 'test*'
        self.assertEquals((1 + 2), 3)
        self.assertEquals(0 + 1, 1)
    def testMultiply(self):
        self.assertEquals((0 * 10), 0)
        self.assertEquals((5 * 8), 40)

if __name__ == '__main__':

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.