Ejemplo n.º 1
0
    def test_equality(self):
        atc1 = xso.AbstractTextChild()
        atc2 = xso.AbstractTextChild()

        self.assertTrue(atc1 == atc2)
        self.assertFalse(atc1 != atc2)

        atc1.text = "foo"

        self.assertFalse(atc1 == atc2)
        self.assertTrue(atc1 != atc2)

        atc2.text = "foo"
        atc2.lang = structs.LanguageTag.fromstr("de-DE")

        self.assertFalse(atc1 == atc2)
        self.assertTrue(atc1 != atc2)

        atc1.lang = atc2.lang

        self.assertTrue(atc1 == atc2)
        self.assertFalse(atc1 != atc2)
Ejemplo n.º 2
0
 def test_equality_handles_incorrect_peer_type_gracefully(self):
     atc = xso.AbstractTextChild()
     self.assertFalse(atc is None)
     self.assertFalse(atc == "foo")
Ejemplo n.º 3
0
 def test_init_default(self):
     atc = xso.AbstractTextChild()
     self.assertIsNone(atc.lang)
     self.assertFalse(atc.text)
Ejemplo n.º 4
0
 def test_init_args(self):
     atc = xso.AbstractTextChild(
         "foo",
         lang=structs.LanguageTag.fromstr("de-DE"))
     self.assertEqual(atc.text, "foo")
     self.assertEqual(atc.lang, structs.LanguageTag.fromstr("de-DE"))
Ejemplo n.º 5
0
 def test_parse(self):
     text, lang = "foo", structs.LanguageTag.fromstr("en-gb")
     item = xso.AbstractTextChild(text, lang)
     self.assertEqual((lang, text), self.type_.parse(item))