def test_iadd(self): """ Tests the __iadd__ method of the Catalog object. """ # 1 - create catalog and add it with another catalog event1 = Event() event2 = Event() event3 = Event() catalog = Catalog([event1]) catalog2 = Catalog([event2, event3]) assert len(catalog) == 1 catalog += catalog2 assert len(catalog) == 3 assert catalog.events == [event1, event2, event3] # 3 - extend it with another Event event4 = Event() assert len(catalog) == 3 catalog += event4 assert len(catalog) == 4 assert catalog.events == [event1, event2, event3, event4] # adding objects other as Catalog or Event should fails with pytest.raises(TypeError): catalog.__iadd__(str) with pytest.raises(TypeError): catalog.__iadd__((event1, event2)) with pytest.raises(TypeError): catalog.__iadd__([event1, event2])