tests: improve testing by splitting tests + use six for basestring python3 compatibility

This commit is contained in:
Gagaro
2014-12-04 11:31:34 +01:00
parent 70b4f2e9b6
commit 8e912f9738
8 changed files with 58 additions and 29 deletions

View File

@@ -11,14 +11,17 @@ class JSignatureFormFieldTest(SimpleTestCase):
f = JSignatureField()
self.assertIsInstance(f.widget, JSignatureWidget)
def test_to_python(self):
def test_to_python_empty_values(self):
f = JSignatureField()
# Empty values
for val in ['', [], '[]']:
self.assertIsNone(f.to_python(val))
# Correct values
def test_to_python_correct_values(self):
f = JSignatureField()
val = '[{"x":[1,2], "y":[3,4]}]'
self.assertEquals([{'x': [1, 2], 'y': [3, 4]}], f.to_python(val))
# Incorrect values
def test_to_python_incorrect_values(self):
f = JSignatureField()
val = 'foo'
self.assertRaises(ValidationError, f.to_python, val)