Exemplo n.º 1
0
 def test_data_range_string_setters_with_strings(self):
     """Test the functions that use strings to set up DataRanges with string vals."""
     # Strings must follow python variable naming conventions, so we don't
     # test strings like '4' or 'some=body'
     with_strings = DataRange("foo_a", "foo_c")
     with_strings.parse_min("(a_p3pp3r_mint")
     self.assertEqual(with_strings.min, 'a_p3pp3r_mint')
     self.assertFalse(with_strings.min_inclusive)
     with_strings.parse_max('spam]')
     self.assertEqual(with_strings.max, 'spam')
     self.assertTrue(with_strings.max_inclusive)
Exemplo n.º 2
0
 def test_data_range_bad_string_setters_min(self):
     """Test invalid string setters for DataRanges. For min only."""
     flipped_inclusivity = DataRange(1,
                                     2,
                                     min_inclusive=False,
                                     max_inclusive=True)
     with_strings = DataRange("foo_a", "foo_c")
     with self.assertRaises(TypeError) as context:
         flipped_inclusivity.parse_min("(cat")
     self.assertIn('Bad type for portion of range', str(context.exception))
     with self.assertRaises(ValueError) as context:
         with_strings.parse_min("spam")
     self.assertIn('Bad inclusiveness specifier', str(context.exception))
Exemplo n.º 3
0
 def test_data_range_string_setters_with_scalars(self):
     """Test the functions that use strings to set up DataRanges with scalar vals."""
     flipped_inclusivity = DataRange(1,
                                     2e100,
                                     min_inclusive=False,
                                     max_inclusive=True)
     flipped_inclusivity.parse_min("[0")
     self.assertEqual(flipped_inclusivity.min, 0)
     self.assertTrue(flipped_inclusivity.min_inclusive)
     flipped_inclusivity.parse_max("4)")
     self.assertEqual(flipped_inclusivity.max, 4)
     self.assertFalse(flipped_inclusivity.max_inclusive)
     # None should automatically set inclusivity to False
     flipped_inclusivity.parse_min("[")
     self.assertIsNone(flipped_inclusivity.min)
     self.assertFalse(flipped_inclusivity.min_inclusive)