Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I receiving a TypeError for an object type int in python?

So I have a project that I am trying to test to see if it is working as expected. Every time I go to test it it says there is a TypeError or it says I'm not taking enough arguments.

this is an example of a test case I'm using:

pirates.process( 0, [( 'Q', 10000 ), ( 'S', 9000), ])

my definition looks like this:

__init__(people_after_me, items)

How do I fix this problem?

Traceback (most recent call last):
  File "F:\lib\unittest\case.py", line 59, in testPartExecutor
   yield
File "F:\lib\unittest\case.py", line 605, in run
 testMethod()
File "C:\Users\Travis Jones\PycharmProjects\pirates\piratesTest.py", line 
12, in test00
   ( 'S',  9000 ),
TypeError: __init__() takes 2 positional arguments but 3 were given
like image 719
Darkhail Avatar asked Mar 12 '26 11:03

Darkhail


1 Answers

If your __init__ is defined within a class, that becomes a method and it should lead with the self argument for the class instance.

Try defining __init__ within the class definition like so.

    def __init__(self, people_after_me, items):
like image 129
metatoaster Avatar answered Mar 15 '26 01:03

metatoaster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!