コード例 #1
0
 def test_owned_list_get_notified_thru_subscript_set_negative(self):
     owner = Owner()
     owned_list = OwnedList([1, 2, 3])
     owned_list.owner = owner
     owned_list[-1] = 9
     self.assertEqual(owned_list, [1, 2, 9])
     self.assertEqual(owner.del_records, [DelRecord(owned_list, 3)])
     self.assertEqual(owner.add_records, [AddRecord(owned_list, 2, 9)])
コード例 #2
0
 def test_owned_list_get_notified_thru_subscript_set(self):
     owner = Owner()
     owned_list = OwnedList([1, 2, 3])
     owned_list.owner = owner
     owned_list[0] = -1
     self.assertEqual(owned_list, [-1, 2, 3])
     self.assertEqual(owner.del_records, [DelRecord(owned_list, 1)])
     self.assertEqual(owner.add_records, [AddRecord(owned_list, 0, -1)])
コード例 #3
0
 def test_owned_list_do_not_get_notified_thru_multiply_equal_sign_1(self):
     owner = Owner()
     owned_list = OwnedList([1, 2])
     owned_list.owner = owner
     owned_list *= 1
     self.assertEqual(owned_list, [1, 2])
     self.assertEqual(owner.add_records, [])
     self.assertEqual(owner.del_records, [])
コード例 #4
0
 def test_owned_list_get_notified_thru_extend(self):
     owner = Owner()
     owned_list = OwnedList([1, 2, 3])
     owned_list.owner = owner
     owned_list.extend([4, 5])
     self.assertEqual(owned_list, [1, 2, 3, 4, 5])
     self.assertEqual(
         owner.add_records,
         [AddRecord(owned_list, 3, 4),
          AddRecord(owned_list, 4, 5)])
コード例 #5
0
 def test_owned_list_get_notified_thru_subscript_slice_del(self):
     owner = Owner()
     owned_list = OwnedList([1, 2, 3, 4, 5])
     owned_list.owner = owner
     del owned_list[1:3]
     self.assertEqual(owned_list, [1, 4, 5])
     self.assertEqual(owner.del_records,
                      [DelRecord(owned_list, 2),
                       DelRecord(owned_list, 3)])
     self.assertEqual(owner.add_records, [])
コード例 #6
0
 def test_owned_list_get_notified_thru_multiply_equal_lt_1(self):
     owner = Owner()
     owned_list = OwnedList([1, 2])
     owned_list.owner = owner
     owned_list *= 0
     self.assertEqual(owned_list, [])
     self.assertEqual(owner.add_records, [])
     self.assertEqual(owner.del_records,
                      [DelRecord(owned_list, 1),
                       DelRecord(owned_list, 2)])
コード例 #7
0
 def test_owned_list_get_notified_thru_plus_equal_sign(self):
     owner = Owner()
     owned_list = OwnedList([1, 2, 3])
     owned_list.owner = owner
     owned_list += [4, 5]
     self.assertEqual(owned_list, [1, 2, 3, 4, 5])
     self.assertEqual(
         owner.add_records,
         [AddRecord(owned_list, 3, 4),
          AddRecord(owned_list, 4, 5)])
コード例 #8
0
 def test_owned_list_get_notified_thru_clear(self):
     owner = Owner()
     owned_list = OwnedList([1, 5, 3])
     owned_list.owner = owner
     owned_list.clear()
     self.assertEqual(owned_list, [])
     self.assertEqual(owner.del_records, [
         DelRecord(owned_list, 1),
         DelRecord(owned_list, 5),
         DelRecord(owned_list, 3)
     ])
コード例 #9
0
 def test_owned_list_get_notified_thru_subscript_slice_set_neg_ovfl(self):
     owner = Owner()
     owned_list = OwnedList([1, 2, 3, 4, 5])
     owned_list.owner = owner
     owned_list[-999:1] = [-1, 0]
     self.assertEqual(owned_list, [-1, 0, 2, 3, 4, 5])
     self.assertEqual(owner.del_records, [DelRecord(owned_list, 1)])
     self.assertEqual(
         owner.add_records,
         [AddRecord(owned_list, 0, -1),
          AddRecord(owned_list, 1, 0)])
コード例 #10
0
 def test_owned_list_get_notified_thru_subscript_slice_set_overflow(self):
     owner = Owner()
     owned_list = OwnedList([1, 2, 3, 4, 5])
     owned_list.owner = owner
     owned_list[100:1] = [6, 7]
     self.assertEqual(owned_list, [1, 2, 3, 4, 5, 6, 7])
     self.assertEqual(owner.del_records, [])
     self.assertEqual(
         owner.add_records,
         [AddRecord(owned_list, 5, 6),
          AddRecord(owned_list, 6, 7)])
コード例 #11
0
 def test_owned_list_get_notified_thru_multiply_equal_sign_gt_1(self):
     owner = Owner()
     owned_list = OwnedList([1, 2])
     owned_list.owner = owner
     owned_list *= 2
     self.assertEqual(owned_list, [1, 2, 1, 2])
     self.assertEqual(
         owner.add_records,
         [AddRecord(owned_list, 2, 1),
          AddRecord(owned_list, 3, 2)])
     self.assertEqual(owner.del_records, [])
コード例 #12
0
 def test_owned_list_get_notified_thru_sub_slice_del_step_neg_ovfl(self):
     owner = Owner()
     owned_list = OwnedList([1, 2, 3, 4, 5])
     owned_list.owner = owner
     del owned_list[-100::2]
     self.assertEqual(owned_list, [2, 4])
     self.assertEqual(owner.del_records, [
         DelRecord(owned_list, 1),
         DelRecord(owned_list, 3),
         DelRecord(owned_list, 5)
     ])
     self.assertEqual(owner.add_records, [])
コード例 #13
0
 def test_owned_list_get_notified_thru_subscript_slice_set(self):
     owner = Owner()
     owned_list = OwnedList([1, 2, 3, 4, 5])
     owned_list.owner = owner
     owned_list[1:3] = [7, 8]
     self.assertEqual(owned_list, [1, 7, 8, 4, 5])
     self.assertEqual(owner.del_records,
                      [DelRecord(owned_list, 2),
                       DelRecord(owned_list, 3)])
     self.assertEqual(
         owner.add_records,
         [AddRecord(owned_list, 1, 7),
          AddRecord(owned_list, 2, 8)])
コード例 #14
0
 def test_owned_list_get_notified_thru_sub_slice_set_step_neg_ovfl(self):
     owner = Owner()
     owned_list = OwnedList([1, 2, 3, 4, 5])
     owned_list.owner = owner
     owned_list[-100::2] = [7, 8, 9]
     self.assertEqual(owned_list, [7, 2, 8, 4, 9])
     self.assertEqual(owner.del_records, [
         DelRecord(owned_list, 1),
         DelRecord(owned_list, 3),
         DelRecord(owned_list, 5)
     ])
     self.assertEqual(owner.add_records, [
         AddRecord(owned_list, 0, 7),
         AddRecord(owned_list, 2, 8),
         AddRecord(owned_list, 4, 9)
     ])
コード例 #15
0
 def test_owned_list_get_notified_thru_subscript_slice_set_neg(self):
     owner = Owner()
     owned_list = OwnedList([1, 2, 3, 4, 5])
     owned_list.owner = owner
     owned_list[-3:] = [7, 8, 9]
     self.assertEqual(owned_list, [1, 2, 7, 8, 9])
     self.assertEqual(owner.del_records, [
         DelRecord(owned_list, 3),
         DelRecord(owned_list, 4),
         DelRecord(owned_list, 5)
     ])
     self.assertEqual(owner.add_records, [
         AddRecord(owned_list, 2, 7),
         AddRecord(owned_list, 3, 8),
         AddRecord(owned_list, 4, 9)
     ])