[Erp5-report] r34924 jerome - in /erp5/trunk/products/Formulator: ./ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon May 3 11:03:59 CEST 2010
Author: jerome
Date: Mon May 3 11:03:56 2010
New Revision: 34924
URL: http://svn.erp5.org?rev=34924&view=rev
Log:
use splitlines instead of split('\n'), because the later does not work in
conjunction with whitespace_preserve.
Modified:
erp5/trunk/products/Formulator/Validator.py
erp5/trunk/products/Formulator/tests/testFormValidator.py
Modified: erp5/trunk/products/Formulator/Validator.py
URL: http://svn.erp5.org/erp5/trunk/products/Formulator/Validator.py?rev=34924&r1=34923&r2=34924&view=diff
==============================================================================
--- erp5/trunk/products/Formulator/Validator.py [utf8] (original)
+++ erp5/trunk/products/Formulator/Validator.py [utf8] Mon May 3 11:03:56 2010
@@ -387,7 +387,7 @@
if max_length and len(value) > max_length:
self.raise_error('too_long', field)
# split input into separate lines
- lines = value.split("\n")
+ lines = value.splitlines()
# check whether we have too many lines
max_lines = field.get_value('max_lines') or 0
Modified: erp5/trunk/products/Formulator/tests/testFormValidator.py
URL: http://svn.erp5.org/erp5/trunk/products/Formulator/tests/testFormValidator.py?rev=34924&r1=34923&r2=34924&view=diff
==============================================================================
--- erp5/trunk/products/Formulator/tests/testFormValidator.py [utf8] (original)
+++ erp5/trunk/products/Formulator/tests/testFormValidator.py [utf8] Mon May 3 11:03:56 2010
@@ -444,6 +444,23 @@
self.assertEquals(10, result.hour())
self.assertEquals(30, result.minute())
+class LinesValidatorTestCase(ValidatorTestCase):
+ def setUp(self):
+ self.v = Validator.LinesValidatorInstance
+
+ def test_basic(self):
+ result = self.v.validate(
+ TestField('f',),
+ 'f', {'f' : 'foo\r\nbar'})
+ self.assertEqual(['foo', 'bar'], result)
+
+ def test_preserve_whitespace(self):
+ result = self.v.validate(
+ TestField('f', whitespace_preserve=True),
+ 'f', {'f' : 'foo\r\nbar '})
+ self.assertEqual(['foo', 'bar '], result)
+
+
def test_suite():
suite = unittest.TestSuite()
@@ -453,6 +470,7 @@
suite.addTest(unittest.makeSuite(IntegerValidatorTestCase, 'test'))
suite.addTest(unittest.makeSuite(FloatValidatorTestCase, 'test'))
suite.addTest(unittest.makeSuite(DateTimeValidatorTestCase, 'test'))
+ suite.addTest(unittest.makeSuite(LinesValidatorTestCase, 'test'))
return suite
More information about the Erp5-report
mailing list