Example #1
0
 def test6(self):
     test_unit = core.enumeration_unit(
         "test", 
         "test",
         [1,4,7]
     )
     self.assertEquals(3, len(list(test_unit.quantities())))  
     for x, y in  zip(test_unit.quantities(), ["1", "4", "7"]):
         self.assertEquals(str(x), y)
Example #2
0
 def test6(self):
     test_unit = core.enumeration_unit(
         "test", 
         "test",
         [1,4,7]
     )
     self.assertEqual(3, len(list(test_unit.quantities())))  
     for x, y in  zip(test_unit.quantities(), ["1", "4", "7"]):
         self.assertEqual(str(x), y)
Example #3
0
 def test3(self):
     test_unit = core.enumeration_unit("test", "test", [1, 2, 3],
                                       ["one", "two", "three"])
     x = 1 | test_unit
     self.assertEquals(1, x.value_in(test_unit))
     self.assertEquals("one", str(x))
     self.assertRaises(
         Exception,
         lambda: 4 | test_unit,
         expected_message="<4> is not a valid value for unit<test>")
Example #4
0
 def test5(self):
     test_unit = core.enumeration_unit(
         "test", 
         "test",
         [1,2,3],
         ["one", "two", "three"]
     )
     self.assertEquals(3, len(list(test_unit.quantities())))  
     for x, y in  zip(test_unit.quantities(), ["one", "two", "three"]):
         self.assertEquals(str(x), y)
Example #5
0
 def test5(self):
     test_unit = core.enumeration_unit(
         "test", 
         "test",
         [1,2,3],
         ["one", "two", "three"]
     )
     self.assertEqual(3, len(list(test_unit.quantities())))  
     for x, y in  zip(test_unit.quantities(), ["one", "two", "three"]):
         self.assertEqual(str(x), y)
Example #6
0
 def test3(self):
     test_unit = core.enumeration_unit(
         "test", 
         "test",
         [1,2,3],
         ["one", "two", "three"]
     )
     x = 1 | test_unit
     self.assertEquals(1, x.value_in(test_unit))    
     self.assertEquals("one", str(x))  
     self.assertRaises(Exception, lambda: 4 | test_unit, 
         expected_message = "<4> is not a valid value for unit<test>")
Example #7
0
 def test7(self):
     test_unit = core.enumeration_unit("test", "test", range(5))
     self.assertEquals(5, len(list(test_unit.quantities())))
     self.assertEquals(1 | test_unit, 1 | test_unit)
     self.assertTrue(1 | test_unit == 1 | test_unit)
     self.assertFalse(1 | test_unit == 2 | test_unit)
     self.assertTrue(1 | test_unit != 2 | test_unit)
     self.assertFalse(1 | test_unit != 1 | test_unit)
     self.assertTrue(1 | test_unit >= 1 | test_unit)
     self.assertFalse(1 | test_unit >= 2 | test_unit)
     self.assertTrue(1 | test_unit <= 1 | test_unit)
     self.assertFalse(1 | test_unit <= 0 | test_unit)
     self.assertTrue(1 | test_unit > 0 | test_unit)
     self.assertFalse(1 | test_unit > 1 | test_unit)
     self.assertTrue(1 | test_unit < 3 | test_unit)
     self.assertFalse(1 | test_unit < 0 | test_unit)
Example #8
0
 def test7(self):
     test_unit = core.enumeration_unit(
         "test", 
         "test",
         range(5)
     )
     self.assertEquals(5, len(list(test_unit.quantities())))
     self.assertEquals(1 | test_unit, 1 | test_unit)
     self.assertTrue (1 | test_unit == 1 | test_unit)
     self.assertFalse(1 | test_unit == 2 | test_unit)
     self.assertTrue (1 | test_unit != 2 | test_unit)
     self.assertFalse(1 | test_unit != 1 | test_unit)
     self.assertTrue (1 | test_unit >= 1 | test_unit)
     self.assertFalse(1 | test_unit >= 2 | test_unit)
     self.assertTrue (1 | test_unit <= 1 | test_unit)
     self.assertFalse(1 | test_unit <= 0 | test_unit)
     self.assertTrue (1 | test_unit >  0 | test_unit)
     self.assertFalse(1 | test_unit >  1 | test_unit)
     self.assertTrue (1 | test_unit <  3 | test_unit)
     self.assertFalse(1 | test_unit <  0 | test_unit)