Skip to content

Commit

Permalink
tests: added isolanguage test
Browse files Browse the repository at this point in the history
  • Loading branch information
cenouralm committed Oct 19, 2020
1 parent 99ff5d4 commit 079378d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/test_isolanguage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2016-2020 CERN.
#
# Marshmallow-Utils is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.

"""Test the marshmallow ISO Language."""

import pytest
from marshmallow import Schema, ValidationError

from marshmallow_utils.fields import ISOLangString


def test_iso639_3_assert():
class MySchema(Schema):
f = ISOLangString()

assert MySchema().load({'f': "tes"}) == {'f': "tes"}


test_data = ["te", "12t", "te!", ",te!"]


@pytest.mark.parametrize('test_input', test_data)
def test_iso639_3_raise(test_input):
class MySchema(Schema):
f = ISOLangString()

for i in test_data:
pytest.raises(ValidationError, MySchema().load, {'f': i})

0 comments on commit 079378d

Please sign in to comment.