forked from orbit-oss/flask
Fix default index for TaggedJSONSerializer.register()
Change the default value of ``index`` to ``None`` in ``register()`` so that it is possible to insert a new tag as the penultimate item in the order list.
This commit is contained in:
parent
16549370fd
commit
fc6a1d9354
2 changed files with 20 additions and 4 deletions
|
|
@ -72,3 +72,19 @@ def test_tag_interface():
|
|||
pytest.raises(NotImplementedError, t.check, None)
|
||||
pytest.raises(NotImplementedError, t.to_json, None)
|
||||
pytest.raises(NotImplementedError, t.to_python, None)
|
||||
|
||||
|
||||
def test_tag_order():
|
||||
class Tag1(JSONTag):
|
||||
key = ' 1'
|
||||
|
||||
class Tag2(JSONTag):
|
||||
key = ' 2'
|
||||
|
||||
s = TaggedJSONSerializer()
|
||||
|
||||
s.register(Tag1, index=-1)
|
||||
assert isinstance(s.order[-2], Tag1)
|
||||
|
||||
s.register(Tag2, index=None)
|
||||
assert isinstance(s.order[-1], Tag2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue