I am getting a strange error that I haven't seen, which is:
__init__() should return None, not 'list'
Surely this has something to do with my case with "None" (that I had problems with earlier). I want to set the capacity to 50 if no capacity is entered (so for example, if container.Container() was called, the size would be 50, but if container.Container(25) was called, it would be 25).
Either way, an empty list should be returned, but it won't let me!
def __init__(self, capacity = None):
self.values = []
if capacity is None:
self.theCapacity = 50
else:
self.theCapacity = capacity
if(self.theCapacity < 1 or isinstance(self.theCapacity, int) == False):
raise ValueError("Container.__init__: invalid capacity")
return self.values
Unit test:
def test1ShouldCreateInstance(self):
self.assertIsInstance(container.Container(25), container.Container)
Can anyone lend a fresh pair of eyes?

New Topic/Question
Reply




MultiQuote




|