Sha256: 9611dbae893abc9865f3a4e28b6e14a98d66dcab5d69e3676fa51745dbd2b9f6

Contents?: true

Size: 994 Bytes

Versions: 2

Compression:

Stored size: 994 Bytes

Contents

#
#     written by Stefano Sanfilippo <a.little.coder@gmail.com>
#

"""Tests for urlencoded unpacker."""

import unittest

from jsbeautifier.unpackers.urlencode import detect, unpack

# pylint: disable=R0904
class TestUrlencode(unittest.TestCase):
    """urlencode test case."""
    def test_detect(self):
        """Test detect() function."""
        encoded = lambda source: self.assertTrue(detect(source))
        unencoded = lambda source: self.assertFalse(detect(source))

        unencoded('')
        unencoded('var a = b')
        encoded('var%20a+=+b')
        encoded('var%20a=b')
        encoded('var%20%21%22')

    def test_unpack(self):
        """Test unpack function."""
        equals = lambda source, result: self.assertEqual(unpack(source), result)

        equals('', '')
        equals('abcd', 'abcd')
        equals('var a = b', 'var a = b')
        equals('var%20a=b', 'var a=b')
        equals('var%20a+=+b', 'var a = b')

if __name__ == '__main__':
    unittest.main()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
js-beautify-0.1.8 js-beautify-copy/python/jsbeautifier/unpackers/tests/testurlencode.py
js-beautify-0.1.7 js-beautify-copy/python/jsbeautifier/unpackers/tests/testurlencode.py