Beispiel #1
0
 def test_trait_utils2(self):
     trait = traits.CTrait(0)
     trait.handler = traits.Float()
     trait.ouptut = True
     trait.optional = False
     manhelp = get_trait_desc("float_trait", trait, 5)
     self.assertEqual(
         manhelp[0],
         "float_trait: a float (['Float'] - mandatory, default value: 5)")
     self.assertEqual(manhelp[1], "    No description.")
Beispiel #2
0
 def test_trait_utils1(self):
     """ Method to test if we can build a string description for a trait.
     """
     trait = traits.CTrait(0)
     trait.handler = traits.Float()
     trait.ouptut = False
     trait.optional = True
     trait.desc = "bla"
     manhelp = get_trait_desc("float_trait", trait, 5)
     self.assertEqual(
         manhelp[0],
         "float_trait: a float (['Float'] - optional, default value: 5)")
     self.assertEqual(manhelp[1], "    bla")
Beispiel #3
0
    def test_trait(self):
        """ Method to test trait characterisitics: value, type.
        """
        self.assertTrue(is_trait_value_defined(5))
        self.assertFalse(is_trait_value_defined(""))
        self.assertFalse(is_trait_value_defined(None))
        self.assertFalse(is_trait_value_defined(traits.Undefined))

        trait = traits.CTrait(0)
        trait.handler = traits.Float()
        self.assertFalse(is_trait_pathname(trait))
        for handler in [traits.File(), traits.Directory()]:
            trait.handler = handler
            self.assertTrue(is_trait_pathname(trait))
Beispiel #4
0
    def test_trait_utils3(self):
        class Blop(object):
            pass

        trait = traits.CTrait(0)
        trait.handler = traits.Instance(Blop())
        trait.ouptut = False
        trait.optional = False
        manhelp = get_trait_desc("blop", trait, None)
        desc = ' '.join([x.strip() for x in manhelp[:-1]])
        self.assertEqual(
            desc, "blop: a Blop or None (['Instance_%s.Blop'] - mandatory)" %
            Blop.__module__)
        self.assertEqual(manhelp[-1], "    No description.")