diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2014-12-14 20:30:52 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2015-03-06 04:41:48 +0100 |
commit | 889d0adab1f303fccabd225e0162ca488ab26164 (patch) | |
tree | ba82a135598a8eae7efcae2ee05897ddda0d0818 /lib/mimeparse/mimeparse_test.py | |
parent | f1d744364619f8d4a5b3609b97b53dfe6b18abb8 (diff) | |
download | samba-889d0adab1f303fccabd225e0162ca488ab26164.tar.gz samba-889d0adab1f303fccabd225e0162ca488ab26164.tar.xz samba-889d0adab1f303fccabd225e0162ca488ab26164.zip |
Remove bundled but unused mimeparse.
Change-Id: I245607c0d27dbeae638f2f50c3b4d560eb9b70f8
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib/mimeparse/mimeparse_test.py')
-rw-r--r-- | lib/mimeparse/mimeparse_test.py | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/lib/mimeparse/mimeparse_test.py b/lib/mimeparse/mimeparse_test.py deleted file mode 100644 index 969cbf35e8..0000000000 --- a/lib/mimeparse/mimeparse_test.py +++ /dev/null @@ -1,68 +0,0 @@ -""" -Python tests for Mime-Type Parser. - -This module loads a json file and converts the tests specified therein to a set -of PyUnitTestCases. Then it uses PyUnit to run them and report their status. -""" -__version__ = "0.1" -__author__ = 'Ade Oshineye' -__email__ = "ade@oshineye.com" -__credits__ = "" - -import mimeparse -import unittest -from functools import partial -# Conditional import to support Python 2.5 -try: - import json -except ImportError: - import simplejson as json - -def test_parse_media_range(args, expected): - expected = tuple(expected) - result = mimeparse.parse_media_range(args) - message = "Expected: '%s' but got %s" % (expected, result) - assert expected == result, message - -def test_quality(args, expected): - result = mimeparse.quality(args[0], args[1]) - message = "Expected: '%s' but got %s" % (expected, result) - assert expected == result, message - -def test_best_match(args, expected): - result = mimeparse.best_match(args[0], args[1]) - message = "Expected: '%s' but got %s" % (expected, result) - assert expected == result, message - -def test_parse_mime_type(args, expected): - expected = tuple(expected) - result = mimeparse.parse_mime_type(args) - message = "Expected: '%s' but got %s" % (expected, result) - assert expected == result, message - -def add_tests(suite, json_object, func_name, test_func): - test_data = json_object[func_name] - for test_datum in test_data: - args, expected = test_datum[0], test_datum[1] - desc = "%s(%s) with expected result: %s" % (func_name, str(args), str(expected)) - if len(test_datum) == 3: - desc = test_datum[2] + " : " + desc - func = partial(test_func, *(args, expected)) - func.__name__ = test_func.__name__ - testcase = unittest.FunctionTestCase(func, description=desc) - suite.addTest(testcase) - -def run_tests(): - json_object = json.load(open("testdata.json")) - - suite = unittest.TestSuite() - add_tests(suite, json_object, "parse_media_range", test_parse_media_range) - add_tests(suite, json_object, "quality", test_quality) - add_tests(suite, json_object, "best_match", test_best_match) - add_tests(suite, json_object, "parse_mime_type", test_parse_mime_type) - - test_runner = unittest.TextTestRunner(verbosity=1) - test_runner.run(suite) - -if __name__ == "__main__": - run_tests() |