def test_regexp(self): """Validation: test that we can check regex patterns on strings.""" from natcap.invest import validation self.assertEqual(None, validation.check_freestyle_string( 1.234, regexp={'pattern': '^1.[0-9]+$', 'case_sensitive': True})) error_msg = validation.check_freestyle_string( 'foobar12', regexp={'pattern': '^[a-zA-Z]+$', 'case_sensitive': True}) self.assertTrue('did not match expected pattern' in error_msg)
def test_float(self): """Validation: test that a float can be a valid string.""" from natcap.invest import validation self.assertEqual(None, validation.check_freestyle_string(1.234))