summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Dennis <rdennis@gmail.com>2014-04-04 17:40:06 -0400
committerRob Dennis <rdennis@gmail.com>2014-04-04 17:40:06 -0400
commite36be928ae339c57b99fe5ec2f9810a3e3c12340 (patch)
treefafcfbce0703edbacbcab6282684cd493ef7ff49
parent21e232572bbb49873a1ef1bd58674c3bb25c4612 (diff)
parentf4f18dd9120274ef7260de31134ab6044f8a4fff (diff)
downloadconfigobj-git-e36be928ae339c57b99fe5ec2f9810a3e3c12340.tar.gz
Merge pull request #45 from robdennis/master
specific test for #44
-rw-r--r--tests/test_configobj.py65
1 files changed, 38 insertions, 27 deletions
diff --git a/tests/test_configobj.py b/tests/test_configobj.py
index 8f95434..98210f1 100644
--- a/tests/test_configobj.py
+++ b/tests/test_configobj.py
@@ -102,33 +102,44 @@ def test_interoplation_repr():
repr(c)
-#issue #18
-def test_unicode_conversion_when_encoding_is_set():
- cfg = """
-test = some string
- """.splitlines()
-
- c = ConfigObj(cfg, encoding='utf8')
-
- if six.PY2:
- assert not isinstance(c['test'], str)
- assert isinstance(c['test'], unicode)
- else:
- assert isinstance(c['test'], str)
-
-
-#issue #18
-def test_no_unicode_conversion_when_encoding_is_omitted():
- cfg = """
-test = some string
- """.splitlines()
-
- c = ConfigObj(cfg)
- if six.PY2:
- assert isinstance(c['test'], str)
- assert not isinstance(c['test'], unicode)
- else:
- assert isinstance(c['test'], str)
+class TestEncoding(object):
+ #issue #18
+ def test_unicode_conversion_when_encoding_is_set(self):
+ cfg = """
+ test = some string
+ """.splitlines()
+
+ c = ConfigObj(cfg, encoding='utf8')
+
+ if six.PY2:
+ assert not isinstance(c['test'], str)
+ assert isinstance(c['test'], unicode)
+ else:
+ assert isinstance(c['test'], str)
+
+
+ #issue #18
+ def test_no_unicode_conversion_when_encoding_is_omitted(self):
+ cfg = """
+ test = some string
+ """.splitlines()
+
+ c = ConfigObj(cfg)
+ if six.PY2:
+ assert isinstance(c['test'], str)
+ assert not isinstance(c['test'], unicode)
+ else:
+ assert isinstance(c['test'], str)
+
+ #issue #44
+ def test_that_encoding_argument_is_used_to_decode(self):
+ cfg = [b'test = \xf0\x9f\x90\x9c']
+
+ c = ConfigObj(cfg, encoding='utf8')
+
+ assert isinstance(c['test'], six.text_type)
+ #TODO: this can be made more explicit if we switch to unicode_literals
+ assert c['test'] == b'\xf0\x9f\x90\x9c'.decode('utf8')
@pytest.fixture