def test_construct_from_another_with_simple_annotations(self): t1 = Taxon("a") t1.annotations.add_new("a", 0) t1.annotations.add_new("b", 1) t1.annotations.add_new("c", 3) for t2 in (Taxon(t1), copy.deepcopy(t1), t1.clone(2)): self.assertIsNot(t1, t2) self.assertNotEqual(t1, t2) self.assertEqual(t1.label, t2.label) self.assertTrue(hasattr(t1, "annotations")) self.assertTrue(hasattr(t2, "annotations")) self.assertEqual(len(t1.annotations), len(t2.annotations)) self.compare_distinct_annotables(t1, t2)
def test_construct_from_another_with_complex_annotations(self): t1 = Taxon("a") t1.annotations.add_new("a", 0) b = t1.annotations.add_new("b", (t1, "label"), is_attribute=True) b.annotations.add_new("c", 3) for t2 in (Taxon(t1), copy.deepcopy(t1), t1.clone(2)): self.assertIsNot(t1, t2) self.assertNotEqual(t1, t2) self.assertEqual(t1.label, t2.label) self.assertTrue(hasattr(t1, "annotations")) self.assertTrue(hasattr(t2, "annotations")) self.assertEqual(len(t1.annotations), len(t2.annotations)) self.compare_distinct_annotables(t1, t2) t1.label = "x" self.assertEqual(t1.annotations[1].value, "x") self.assertEqual(t2.annotations[1].value, "a") t2.label = "z" self.assertEqual(t1.annotations[1].value, "x") self.assertEqual(t2.annotations[1].value, "z") t1.label = "a"
def test_construct_from_another(self): t1 = Taxon("a") for t2 in (Taxon(t1), copy.deepcopy(t1), t1.clone(2)): self.assertIsNot(t1, t2) self.assertNotEqual(t1, t2) self.assertEqual(t1.label, t2.label)
def test_taxon_namespace_scoped_copy(self): t1 = Taxon("a") for t2 in (t1.clone(1), t1.taxon_namespace_scoped_copy()): self.assertIs(t2, t1)
def test_simple_copy(self): t1 = Taxon("a") with self.assertRaises(TypeError): copy.copy(t1) with self.assertRaises(TypeError): t1.clone(0)