示例#1
0
 def test_is_of_false_unrelated(self):
     t_liquid = RxType("liquid")
     t_solid = RxType("solid")
     type_set = RxTypeSet()
     type_set._types = {"liquid": t_liquid, "solid": t_solid}
     self.assertFalse(type_set.is_of("solid", "liquid"))
     self.assertFalse(type_set.is_of("liquid", "solid"))
示例#2
0
 def test_is_one_of_false_hierarchy(self):
     t_liquid = RxType("liquid")
     t_water = RxType("water", t_liquid)
     t_lake = RxType("lake", t_water)
     type_set = RxTypeSet()
     type_set._types = {"liquid": t_liquid}
     self.assertFalse(type_set.is_one_of("liquid", ["water", "lake"]))
示例#3
0
    def test_is_of_excluded(self):
        t_liquid = RxType("liquid")
        t_water = RxType("water", t_liquid)
        type_set = RxTypeSet()
        type_set._types = {"liquid": t_liquid}

        with self.assertRaises(KeyError):
            type_set.is_of("water", "liquid")
示例#4
0
 def test_is_one_of_false_unrelated(self):
     t_liquid = RxType("liquid")
     t_solid = RxType("solid")
     t_gas = RxType("gas")
     t_plasma = RxType("plasma")
     type_set = RxTypeSet()
     type_set._types = {"plasma": t_plasma}
     self.assertFalse(
         type_set.is_one_of("plasma", ["liquid", "solid", "gas"]))
示例#5
0
 def test_is_one_of_true(self):
     t_liquid = RxType("liquid")
     t_solid = RxType("solid")
     t_gas = RxType("gas")
     t_water = RxType("water", t_liquid)
     type_set = RxTypeSet()
     type_set._types = {"water": t_water}
     self.assertTrue(type_set.is_one_of("water",
                                        ["liquid", "solid", "gas"]))
示例#6
0
    def test_is_of_true(self):

        t_liquid = RxType("liquid")
        t_water = RxType("water", t_liquid)
        t_lake = RxType("lake", t_water)
        type_set = RxTypeSet()
        type_set._types = {"water": t_water, "lake": t_lake}
        self.assertTrue(type_set.is_of("water", "liquid"))
        self.assertTrue(type_set.is_of("lake", "water"))
示例#7
0
    def test_get_full_type_names(self):
        t_liquid = RxType("liquid")
        t_water = RxType("water", t_liquid)
        t_lake = RxType("lake", t_water)
        type_set = RxTypeSet()
        type_set._types = {
            "liquid": t_liquid,
            "water": t_water,
            "lake": t_lake
        }

        self.assertEqual(type_set.get_full_type_names("liquid"), ["liquid"])
        self.assertEqual(type_set.get_full_type_names("water"),
                         ["water", "liquid"])
        self.assertEqual(type_set.get_full_type_names("lake"),
                         ["lake", "water", "liquid"])
示例#8
0
    def test_getitem(self):

        rxtype = RxType("liquid")
        type_set = RxTypeSet()
        type_set._types = {"liquid": rxtype}
        self.assertEqual(type_set["liquid"], rxtype)