コード例 #1
0
 def test_removal(self):
     obj_list = DictList(Object("test%d" % (i)) for i in range(2, 10))
     del obj_list[3]
     assert "test5" not in obj_list
     assert obj_list.index(obj_list[-1]) == len(obj_list) - 1
     assert len(obj_list) == 7
     del obj_list[3:5]
     assert "test6" not in obj_list
     assert "test7" not in obj_list
     assert obj_list.index(obj_list[-1]) == len(obj_list) - 1
     assert len(obj_list) == 5
     removed = obj_list.pop(1)
     assert obj_list.index(obj_list[-1]) == len(obj_list) - 1
     assert removed.id == "test3"
     assert "test3" not in obj_list
     assert len(obj_list) == 4
     removed = obj_list.pop()
     assert removed.id == "test9"
     assert removed.id not in obj_list
     assert len(obj_list) == 3
コード例 #2
0
 def testRemoval(self):
     obj_list = DictList(Object("test%d" % (i)) for i in range(2, 10))
     del obj_list[3]
     self.assertNotIn("test5", obj_list)
     self.assertEqual(obj_list.index(obj_list[-1]), len(obj_list) - 1)
     self.assertEqual(len(obj_list), 7)
     del obj_list[3:5]
     self.assertNotIn("test6", obj_list)
     self.assertNotIn("test7", obj_list)
     self.assertEqual(obj_list.index(obj_list[-1]), len(obj_list) - 1)
     self.assertEqual(len(obj_list), 5)
     removed = obj_list.pop(1)
     self.assertEqual(obj_list.index(obj_list[-1]), len(obj_list) - 1)
     self.assertEqual(removed.id, "test3")
     self.assertNotIn("test3", obj_list)
     self.assertEqual(len(obj_list), 4)
     removed = obj_list.pop()
     self.assertEqual(removed.id, "test9")
     self.assertNotIn(removed.id, obj_list)
     self.assertEqual(len(obj_list), 3)
コード例 #3
0
ファイル: test_util.py プロジェクト: mmundy42/cobrapy
 def test_removal(self):
     obj_list = DictList(Object("test%d" % (i)) for i in range(2, 10))
     del obj_list[3]
     assert "test5" not in obj_list
     assert obj_list.index(obj_list[-1]) == len(obj_list) - 1
     assert len(obj_list) == 7
     del obj_list[3:5]
     assert "test6" not in obj_list
     assert "test7" not in obj_list
     assert obj_list.index(obj_list[-1]) == len(obj_list) - 1
     assert len(obj_list) == 5
     removed = obj_list.pop(1)
     assert obj_list.index(obj_list[-1]) == len(obj_list) - 1
     assert removed.id == "test3"
     assert "test3" not in obj_list
     assert len(obj_list) == 4
     removed = obj_list.pop()
     assert removed.id == "test9"
     assert removed.id not in obj_list
     assert len(obj_list) == 3