diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-01-02 09:37:52 -0600 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-01-02 09:37:52 -0600 |
commit | eb390a6ff1ad4c0d846b79f818a087fd917cf0c4 (patch) | |
tree | 9feb83ee02af3e343531b38476637523cd1faec3 /test_six.py | |
parent | 4ee381cc51904981b3a9da0e11f21c71ec82837f (diff) | |
parent | 5ddcb9e038680badbeef5a560311f16099b7e9ea (diff) | |
download | six-git-eb390a6ff1ad4c0d846b79f818a087fd917cf0c4.tar.gz |
Merged in graingert/six (pull request #48)
Diffstat (limited to 'test_six.py')
-rw-r--r-- | test_six.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test_six.py b/test_six.py index 2a9ca74..4e95394 100644 --- a/test_six.py +++ b/test_six.py @@ -822,3 +822,24 @@ def test_assertRaisesRegex(): raise AssertionError('Bar') TestAssertRaisesRegex('test').test() + + +def test_python_2_unicode_compatible(): + @six.python_2_unicode_compatible + class MyTest(object): + def __str__(self): + return six.u('hello') + + def __bytes__(self): + return six.b('hello') + + my_test = MyTest() + + if six.PY2: + assert str(my_test) == six.b("hello") + assert unicode(my_test) == six.u("hello") + elif six.PY3: + assert bytes(my_test) == six.b("hello") + assert str(my_test) == six.u("hello") + + assert getattr(six.moves.builtins, 'bytes', str)(my_test) == six.b("hello") |