FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlobject/sqlobject/tests/test_constraints.py at master · sqlobject/sqlobject · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
sqlobject
/
sqlobject
Public
Notifications
You must be signed in to change notification settings
Fork
26
Star
156
Code
Issues
2
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlobject
/
sqlobject
/
tests
/
test_constraints.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (36 loc) · 1.25 KB
Breadcrumbs
sqlobject
/
sqlobject
/
tests
/
test_constraints.py
Copy path
File metadata and controls
43 lines (36 loc) · 1.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
from
sqlobject
.
compat
import
PY2
from
sqlobject
.
constraints
import
BadValue
,
InList
,
MaxLength
, \
isFloat
,
isInt
,
isString
,
notNull
from
sqlobject
.
tests
.
dbtest
import
Dummy
,
raises
if
not
PY2
:
# alias for python 3 compatability
long
=
int
def
test_constraints
():
obj
=
'Test object'
col
=
Dummy
(
name
=
'col'
)
isString
(
obj
,
col
,
'blah'
)
raises
(
BadValue
,
isString
,
obj
,
col
,
1
)
if
PY2
:
# @@: Should this really be an error?
raises
(
BadValue
,
isString
,
obj
,
col
,
u'test!'
)
else
:
raises
(
BadValue
,
isString
,
obj
,
col
,
b'test!'
)
# isString(obj, col, u'test!')
raises
(
BadValue
,
notNull
,
obj
,
col
,
None
)
raises
(
BadValue
,
isInt
,
obj
,
col
,
1.1
)
isInt
(
obj
,
col
,
1
)
isInt
(
obj
,
col
,
long
(
1
))
isFloat
(
obj
,
col
,
1
)
isFloat
(
obj
,
col
,
long
(
1
))
isFloat
(
obj
,
col
,
1.2
)
raises
(
BadValue
,
isFloat
,
obj
,
col
,
'1.0'
)
# @@: Should test isBool, but I don't think isBool is right
lst
=
InList
((
'a'
,
'b'
,
'c'
))
lst
(
obj
,
col
,
'a'
)
raises
(
BadValue
,
lst
,
obj
,
col
, (
'a'
,
'b'
,
'c'
))
raises
(
BadValue
,
lst
,
obj
,
col
,
'A'
)
maxlen
=
MaxLength
(
2
)
raises
(
BadValue
,
maxlen
,
obj
,
col
,
'123'
)
maxlen
(
obj
,
col
,
'12'
)
maxlen
(
obj
,
col
, (
1
,))
raises
(
BadValue
,
maxlen
,
obj
,
col
,
1
)
Back
|
FazBrowse Home
|
New Git URL