diff options
author | David Lord <davidism@gmail.com> | 2018-05-04 13:28:40 -0700 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2018-05-04 13:28:40 -0700 |
commit | 3fe4a11f139eba8711c7194a4a05e5bbd9a36786 (patch) | |
tree | 68a34fb0ccc3ac579dafa8de35d6cc237e72f200 /tests | |
parent | 2f931bd8b101c572a431255d35efcf2c177e1630 (diff) | |
download | markupsafe-3fe4a11f139eba8711c7194a4a05e5bbd9a36786.tar.gz |
convert to pytest
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_escape.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_escape.py b/tests/test_escape.py new file mode 100644 index 0000000..cf09d6a --- /dev/null +++ b/tests/test_escape.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +import pytest + +from markupsafe import Markup, _native + +try: + from markupsafe import _speedups +except ImportError: + _speedups = None + + +@pytest.mark.parametrize('mod', ( + _native, + pytest.param(_speedups, marks=pytest.mark.skipif( + _speedups is None, reason='speedups unavailable')), +)) +@pytest.mark.parametrize(('value', 'expect'), ( + # empty + (u'', u''), + # ascii + (u'abcd&><\'"efgh', u'abcd&><'"efgh'), + (u'&><\'"efgh', u'&><'"efgh'), + (u'abcd&><\'"', u'abcd&><'"'), + # 2 byte + (u'こんにちは&><\'"こんばんは', + u'こんにちは&><'"こんばんは'), + (u'&><\'"こんばんは', u'&><'"こんばんは'), + (u'こんにちは&><\'"', u'こんにちは&><'"'), + # 4 byte + (u'\U0001F363\U0001F362&><\'"\U0001F37A xyz', u'\U0001F363\U0001F362&><'"\U0001F37A xyz'), + (u'&><\'"\U0001F37A xyz', u'&><'"\U0001F37A xyz'), + (u'\U0001F363\U0001F362&><\'"', u'\U0001F363\U0001F362&><'"'), +)) +def test_escape(mod, value, expect): + assert mod.escape(value) == Markup(expect) |