示例#1
0
 def test_other_disallowed(self):
     instance = create_instance(String())
     with self.assertRaises(TypeError):
         instance.attr = tuple()
示例#2
0
 def test_unicode_allowed(self):
     instance = create_instance(String())
     instance.attr = u'abc'
     self.assertEqual(u'abc', instance.attr)
示例#3
0
 def test_empty_string(self):
     instance = create_instance(String())
     instance.attr = ''
     self.assertEqual('', instance.attr)
示例#4
0
 def test_native_str_allowed(self):
     instance = create_instance(String())
     instance.attr = str('abc')
     self.assertEqual('abc', instance.attr)
示例#5
0
 def test_bytes_allowed(self):
     instance = create_instance(String())
     instance.attr = b'abc'
     self.assertEqual(b'abc', instance.attr)
示例#6
0
 def test_default_handling(self):
     instance = create_instance(String(default='abc'))
     self.assertEqual('abc', instance.attr)
示例#7
0
 def test_empty_string(self):
     instance = create_instance(String())
     instance.attr = ""
     assert "" == instance.attr
示例#8
0
 def test_unicode_allowed(self):
     instance = create_instance(String())
     instance.attr = "abc"
     assert "abc" == instance.attr
示例#9
0
 def test_native_str_allowed(self):
     instance = create_instance(String())
     instance.attr = "abc"
     assert "abc" == instance.attr
示例#10
0
 def test_default_handling(self):
     instance = create_instance(String(default="abc"))
     assert "abc" == instance.attr