summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDB Tsai <dbtsai@dbtsai.com>2016-01-27 12:25:39 -0800
committerDB Tsai <dbtsai@dbtsai.com>2016-01-27 12:25:39 -0800
commit80c9bf6afe315006680094dc8bf236658db4526c (patch)
tree1f50c577342cdcafd0b45a2870bc8453f9404b0a
parent2552c7b936433d5d3f8b02d427a4ed15d68e24b2 (diff)
parent1df55be08efe6d6c2064e670671e50055aeb1276 (diff)
downloadpython-mimeparse-80c9bf6afe315006680094dc8bf236658db4526c.tar.gz
Merge pull request #9 from wojcikstefan/pep8-tweaks
pep8 tweaks + remove unused test code
-rw-r--r--.travis.yml1
-rw-r--r--README6
-rwxr-xr-xmimeparse.py2
-rwxr-xr-xmimeparse_test.py16
4 files changed, 7 insertions, 18 deletions
diff --git a/.travis.yml b/.travis.yml
index cb5b1e1..dde1451 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,6 @@ python:
env:
- TOXENV=py27
- - TOXENV=py32
- TOXENV=py34
- TOXENV=pypy
- TOXENV=pep8,pyflakes
diff --git a/README b/README
index d5c925d..0b43d2c 100644
--- a/README
+++ b/README
@@ -21,4 +21,8 @@ Python
The Python tests require Python 2.6.
Run the tests by typing:
-python mimeparse_test.py \ No newline at end of file
+python mimeparse_test.py
+
+To make sure that the package works in all the supported environments, you can run tox tests:
+pip install tox
+tox
diff --git a/mimeparse.py b/mimeparse.py
index c8047e7..1e06cc1 100755
--- a/mimeparse.py
+++ b/mimeparse.py
@@ -51,7 +51,7 @@ def parse_mime_type(mime_type):
full_type = '*/*'
if '/' not in full_type:
- raise MimeTypeParseException(u"Can't parse type \"{}\"".format(full_type))
+ raise MimeTypeParseException("Can't parse type \"{}\"".format(full_type))
(type, subtype) = full_type.split('/')
diff --git a/mimeparse_test.py b/mimeparse_test.py
index 0ca36c8..6d00238 100755
--- a/mimeparse_test.py
+++ b/mimeparse_test.py
@@ -8,7 +8,6 @@ of PyUnitTestCases. Then it uses PyUnit to run them and report their status.
import json
import mimeparse
import unittest
-from functools import partial
__version__ = "0.1"
@@ -16,6 +15,7 @@ __author__ = 'Ade Oshineye'
__email__ = "ade@oshineye.com"
__credits__ = ""
+
class MimeParseTestCase(unittest.TestCase):
def setUp(self):
@@ -29,13 +29,11 @@ class MimeParseTestCase(unittest.TestCase):
message = "Expected: '%s' but got %s" % (expected, result)
self.assertEqual(expected, result, message)
-
def _test_quality(self, args, expected):
result = mimeparse.quality(args[0], args[1])
message = "Expected: '%s' but got %s" % (expected, result)
self.assertEqual(expected, result, message)
-
def _test_best_match(self, args, expected, description):
if expected is None:
self.assertRaises(mimeparse.MimeTypeParseException, mimeparse.best_match, args[0], args[1])
@@ -69,18 +67,6 @@ class MimeParseTestCase(unittest.TestCase):
for args, expected in self.test_data['parse_mime_type']:
self._test_parse_mime_type(args, expected)
-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__':
unittest.main()