Search code examples
pythonpython-2.7nosenosetests

Environmental causes of module.__init()__ takes at most 2 arguments (3 given) ? - python 2.7


I have two machines with my python module installed on it (the module is a series of selenium tests)

To run the test suite, I call python runner.py --user <user>

On the first machine, everything works fine. On the second machine I get the following error:

TypeError: Error when calling metaclass bases
    module.__init__() takes a most 2 arguments (3 given)

This is not a code issue becuase the code on these two machines is the exact same - I install the module via a .whl

What environmental issues could cause such an error?

======================================================================
ERROR: Failure: TypeError (Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\nose\loader.py", line 418, in loadTestsFromName
 addr.filename, addr.module)
  File "C:\Python27\lib\site-packages\nose\importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "C:\Python27\lib\site-packages\nose\importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "C:\Python27\lib\site-packages\seleniumTestSuite\speed_loading_settings_45672_tes
    t.py", line 23, in <module>
    class Settings_LoadQuickly_45672(unittest.TestCase):
TypeError: Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)

----------------------------------------------------------------------

Solution

  • Wow, figured it out -- the top __init__.py in my module had been deleted from the failing machine.

    MyModule
        __init__.py   <-- This was deleted!!
        Lib
            __init__.py
            <core_py_files>
        Tests
            __init__.py
            <test_files>
        Settings
            __init__.py
            <settings_files>
        test_runner.py
    

    Hope this answer helps someone else, because that error is super non-transparent.