Skip to content

Commit

Permalink
Add formencode test on PY3 and update variable_decode test to new for…
Browse files Browse the repository at this point in the history
…mencode behavior
  • Loading branch information
amol- committed Dec 7, 2013
1 parent 707c90d commit 253c48b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -24,7 +24,8 @@
'routes',
'backlash',
'sqlalchemy',
'raven'
'raven',
'formencode>=1.3.0a1'
]

if py_version == (3, 2):
Expand All @@ -39,7 +40,6 @@
'Kajiki >= 0.2.2',
'Chameleon < 2.0a',
'simplegeneric',
'Formencode',
'routes',
'tgming',
'tw.forms',
Expand Down
21 changes: 13 additions & 8 deletions tests/test_stack/dispatch/test_decorated_controller.py
Expand Up @@ -144,19 +144,24 @@ def setup(self):
self.app = app_from_config(base_config)

def test_variabledecode_fail(self):
if PY3: raise SkipTest()

resp = self.app.get('/test_vardec', params={'test-1':'1', 'test-2':2, 'test-':4})
resp = self.app.get('/test_vardec', params={'test-1': '1',
'test-2': 2,
'test--repetitions': 'hi'})
assert resp.json['test-1'] == '1', resp.json
assert resp.json['test--repetitions'] == 'hi', resp.json
assert 'test' not in resp.json, resp.json

def test_variabledecode_partial_fail(self):
resp = self.app.get('/test_vardec', params={'test-1': '1',
'test-2': 2,
'test-': 4})
assert resp.json['test-1'] == '1'
assert resp.json['test-'] == '4'
assert len(resp.json['test']) == 2

def test_variable_decode(self):
if PY3: raise SkipTest()

from formencode.variabledecode import variable_encode
obj = dict(
a=['1','2','3'],
b=dict(c=[dict(d='1')]))
obj = dict(a=['1','2','3'], b=dict(c=[dict(d='1')]))
params = variable_encode(dict(obj=obj), add_repetitions=False)
resp = self.app.get('/test_vardec', params=params)
assert resp.json['obj'] == obj, (resp.json['obj'], obj)
Expand Down

0 comments on commit 253c48b

Please sign in to comment.