TypeError: object.__init__() takes no parameters

Oliver wildeskraut at googlemail.com
Fri Sep 9 01:47:34 EDT 2011


Hello together,

let me be honest with you, I am a poor programmer who can only do
Perl.
I tried to code a program in Perl, but found that another guy already
finished this job in Python.
Unlucky for me, this guy is now CEO of a company, not really
interested in supporting his old code.

If I want to run shapes.py I receive this error message:

=== error message ===

C:\Documents and Settings\mhg\Desktop\palcalc>shapes.py
EE...
======================================================================
ERROR: test_fits (__main__.containerTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Documents and Settings\mhg\Desktop\palcalc\shapes.py", line
265, in test_fits
    cont = Container()
  File "C:\Documents and Settings\mhg\Desktop\palcalc\shapes.py", line
90, in __init__
    super(Container, self).__init__(xsize, ysize)
TypeError: object.__init__() takes no parameters

======================================================================
ERROR: test_place_bin (__main__.containerTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Documents and Settings\mhg\Desktop\palcalc\shapes.py", line
257, in test_place_bin
    cont = Container()
  File "C:\Documents and Settings\mhg\Desktop\palcalc\shapes.py", line
90, in __init__
    super(Container, self).__init__(xsize, ysize)
TypeError: object.__init__() takes no parameters

----------------------------------------------------------------------
Ran 5 tests in 0.032s

FAILED (errors=2)

=== end of error message ===

Snippets of source code:

Line 264 - 268

def test_fits(self):
        cont = Container()
        cont.place_bin(0, 0, 210, 280)
        self.assertEqual(False, cont.fits(Rectangle(0, 210, 280,
420)))
        self.assertEqual(True, cont.fits(Rectangle(0, 280, 280, 490)))

Line 87 - 93

class Container(object):
    """Container to store  a number of non-overlapping rectangles."""
    def __init__(self, xsize=1200, ysize=800):
        super(Container, self).__init__(xsize, ysize)
        self.rect = Rectangle(0, 0, xsize, ysize)
        self.boxes = []
        self.last_placement_strategy = 0

Line 254 - 262

class containerTests(unittest.TestCase):
    """Tests for container objects."""
    def test_place_bin(self):
        cont = Container()
        cont.place_bin(0, 0, 40, 40)
        self.failUnlessRaises(RuntimeError, cont.place_bin, 0, 0, 40,
40)
        cont = Container()
        cont.place_bin(0, 0, 210, 280)
        self.failUnlessRaises(RuntimeError, cont.place_bin, 0, 210,
280, 420)

I think this is the main function:

if __name__ == '__main__':
    unittest.main()

I do not know if I posted what you need to help me, it just would ease
my life a lot. If you need more information please let me know - if
you want you can even be unfriendly to me :)



More information about the Python-list mailing list