def test_add(self): g1 = self.create_group() g2 = IPADescriptorGroup([IPADescriptor([u"foobar"])]) g = g1 + g2 self.assertNotEqual(g, g1) self.assertNotEqual(g, g2) self.assertTrue(u"foo" in g) self.assertTrue(u"bar" in g) self.assertTrue(u"baz" in g) self.assertTrue(u"foobar" in g) self.assertEqual(len(g), len(g1) + len(g2))
def test_init_bad(self): values = [ None, [], "foo", u"foo", { "k": "v" }, ] for v in values: with self.assertRaises((TypeError, ValueError)): d = IPADescriptor(v)
def create_group(self): d1 = IPADescriptor([u"foo", u"bar"]) d2 = IPADescriptor([u"baz"]) d3 = IPADescriptor([u"foobarbaz"]) return IPADescriptorGroup([d1, d2, d3])
def test_in(self): d = IPADescriptor([u"foo", u"bar"]) self.assertTrue(u"foo" in d) self.assertTrue(u"bar" in d) self.assertTrue("foo" in d) self.assertTrue("bar" in d)
def test_labels_set(self): d = IPADescriptor([u"foo", u"bar"]) with self.assertRaises(ValueError): d.labels = set([u"bar"])
def test_labels_get(self): d = IPADescriptor([u"foo", u"bar"]) self.assertEqual(d.labels, [u"foo", u"bar"])
def test_canonical_label_set(self): d = IPADescriptor([u"foo", u"bar"]) with self.assertRaises(ValueError): d.canonical_label = u"bar"
def test_canonical_label_get(self): d = IPADescriptor([u"foo", u"bar"]) self.assertEqual(d.canonical_label, u"foo")
def test_init(self): d = IPADescriptor([u"foo", u"bar"])