/usr/lib/python2.7/dist-packages/formencode/tests/non_empty.txt is in python-formencode 1.3.0-0ubuntu5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | michele@ionic:~/Progetti/TurboGears/svn/thirdparty/formencode/formencode$ python
Python 2.4.3 (#2, Mar 30 2006, 14:45:01)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from formencode import validators
>>> int = validators.Int()
>>> int.not_empty
False
>>> int.to_python('')
>>> int.to_python(None)
>>> int.to_python(0)
0
>>> int.to_python(False)
0
>>> int.to_python('1')
1
>>> int.to_python('1a')
Traceback (most recent call last):
...
Invalid: Please enter an integer value
>>> int.not_empty = True
>>> int.to_python('')
Traceback (most recent call last):
...
Invalid: Please enter a value
>>> int.to_python(None)
Traceback (most recent call last):
...
Invalid: Please enter a value
>>> int.to_python('1')
1
>>> int.to_python('1a')
Traceback (most recent call last):
...
Invalid: Please enter an integer value
>>> from formencode import compound
>>> any = compound.Any(validators.Int(), validators.NotEmpty())
>>> any.not_empty
False
>>> any.to_python('')
>>> any.to_python(None)
>>> any = compound.Any(validators.Int(), validators.Empty())
>>> any.not_empty
False
>>> any = compound.All(validators.Int(), validators.NotEmpty())
>>> any.not_empty
True
>>> any.to_python('')
Traceback (most recent call last):
...
Invalid: Please enter a value
>>> from formencode.foreach import ForEach
>>> from formencode.validators import Int
>>> foreach = ForEach(Int())
>>> foreach.to_python('')
[]
>>> foreach.to_python(None)
[]
>>> foreach.to_python('1')
[1]
>>> foreach.to_python('2')
[2]
>>> foreach.to_python(['2', '3'])
[2, 3]
>>> foreach.not_empty = True
>>> foreach.to_python('1')
[1]
>>> foreach.to_python('')
Traceback (most recent call last):
...
Invalid: Please enter a value
>>> foreach.if_empty = []
>>> foreach.to_python('')
Traceback (most recent call last):
...
Invalid: Please enter a value
>>> foreach.not_empty = False
>>> foreach.to_python('')
[]
>>> foreach.not_empty = False
|