~ubuntu-branches/ubuntu/oneiric/python-formencode/oneiric

« back to all changes in this revision

Viewing changes to tests/non_empty.txt

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2011-06-08 09:45:26 UTC
  • mfrom: (1.1.5 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20110608094526-lxaax4w9wsiqz1cw
Tags: 1.2.4-2ubuntu1
* Merge from debian unstable (LP: #789176).  Remaining changes:
  - debian/control: Suggest python-dns.

Show diffs side-by-side

added added

removed removed

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