I have a function written here:
def addItem(aBookcase, name, mediaType):
Returns False if aBookcase is full, otherwise returns True and
adds item of given name and mediaType to aBookcase.
emptySpacesBefore = aBookcase.getEmptySpaces()
if aBookcase.getEmptySpaces() == 0:
added = False
position = findSpace(aBookcase)
added = True
emptySpacesAfter = aBookcase.getEmptySpaces()
assert added is True, "No free positions"
assert emptySpacesAfter < emptySpacesBefore, "Same amount of empty spaces"
assert aBookcase.getName(*position) is name, "Error with name"
assert aBookcase.getType(*position) is mediaType, "Error with media type"
assert addItem(small, "Algorhythms, date structures and compatibility", BOOK)
when it works properly, your
addItem function returns nothing, so it returns
None, which is seen as a failure by the last
assert statement that you inserted. You should return
added for both cases (
BTW since you reached that line, it means that all previous assertions are OK so good news: your code is OK.