Example #1
0
 def test_converting_to_python_rejects_non_byte_string(self):
     example = factory.make_string()
     validator = config.ByteString()
     error = self.assertRaises(formencode.Invalid, validator.to_python,
                               example)
     self.assertThat(
         str(error),
         Equals("The input must be a byte string (not a str: %r)" %
                example))
Example #2
0
 def test_empty_value(self):
     validator = config.ByteString()
     self.assertThat(validator.to_python(None), Equals(b""))
Example #3
0
 def test_converting_to_python_accepts_byte_string(self):
     example = factory.make_bytes()
     validator = config.ByteString()
     self.assertThat(validator.to_python(example), Equals(example))