DEV Community

Discussion on: Implement a Queue using a List.

Collapse
 
tdhirendra12 profile image
Jesse

Just want to know why we can't create quue object inside main function and pass the ref of queue.size fun'c to test function it gives error like required positional argument ... Can you help?

Collapse
 
codewithml profile image
CodeWithML

I'm assuming you didn't add the second argument.

def main():
    test = TestQueueList()
    queue1 = Queue()
    queue1.enqueue(5)
    test.assertEqual(queue1.size()) 

The second argument required will be the value returned by the function size.
assertEqual compares two values, if both match then the test case will pass, otherwise it will fail.
You should write it like this, in main function

def main():
    test = TestQueueList()
   # Testing inside main function
    queue1 = Queue()
    queue1.enqueue(5)
    test.assertEqual(queue1.size(), 1) 

This will work.