summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTres Seaver <tseaver@palladion.com>2015-02-23 16:44:20 -0500
committerTres Seaver <tseaver@palladion.com>2015-02-23 16:44:20 -0500
commitefb90f8a49e7099ff2631c61eb505971acb51d76 (patch)
tree95a58e9a821c2febce1a88578660e798fa0855bf
parentdfb114728c8946333d2b8bf561755e1c7ed4d0a7 (diff)
downloadzope-contenttype-efb90f8a49e7099ff2631c61eb505971acb51d76.tar.gz
Require 100% coverage.
-rw-r--r--src/zope/contenttype/__init__.py2
-rw-r--r--src/zope/contenttype/parse.py7
-rw-r--r--src/zope/contenttype/tests/test_parse.py9
3 files changed, 11 insertions, 7 deletions
diff --git a/src/zope/contenttype/__init__.py b/src/zope/contenttype/__init__.py
index cededc4..0724a56 100644
--- a/src/zope/contenttype/__init__.py
+++ b/src/zope/contenttype/__init__.py
@@ -105,7 +105,7 @@ here = os.path.dirname(os.path.abspath(__file__))
add_files([os.path.join(here, "mime.types")])
# Python 2/3 compatibility for testing.
-def _print(s):
+def _print(s): # pragma: NO COVER
print(s)
def main():
diff --git a/src/zope/contenttype/parse.py b/src/zope/contenttype/parse.py
index 5978da3..27fde81 100644
--- a/src/zope/contenttype/parse.py
+++ b/src/zope/contenttype/parse.py
@@ -86,12 +86,7 @@ def _parse_params(string):
return result
-def _quoted_string_match(string):
- # This support RFC 822 quoted-string values.
- global _quoted_string_match
- _quoted_string_match = re.compile(
- '"(?:\\\\.|[^"\n\r\\\\])*"', re.DOTALL).match
- return _quoted_string_match(string)
+_quoted_string_match = re.compile('"(?:\\\\.|[^"\n\r\\\\])*"', re.DOTALL).match
def _check_token(string):
if _token_match(string) is None:
diff --git a/src/zope/contenttype/tests/test_parse.py b/src/zope/contenttype/tests/test_parse.py
index dd2fffd..04490af 100644
--- a/src/zope/contenttype/tests/test_parse.py
+++ b/src/zope/contenttype/tests/test_parse.py
@@ -31,6 +31,9 @@ class ParseOrderedTestCase(unittest.TestCase):
def oneParam(self, name, value):
return [(name, value)]
+ def test_invalid_type(self):
+ self.assertRaises(ValueError, self._callFUT, 'no-slash-here')
+
def test_without_params(self):
self.assertEqual(self._callFUT("text/plain"),
("text", "plain", self.empty_params))
@@ -41,6 +44,12 @@ class ParseOrderedTestCase(unittest.TestCase):
self.assertEqual(self._callFUT("text / vnd.wap.wml"),
("text", "vnd.wap.wml", self.empty_params))
+ def test_invalid_params(self):
+ self.assertRaises(ValueError,
+ self._callFUT, 'text/plain; foo="abc')
+ self.assertRaises(ValueError,
+ self._callFUT, 'text/plain; foo="abc" bar')
+
def test_with_empty_params(self):
self.assertEqual(self._callFUT("text/plain ; "),
("text", "plain", self.empty_params))