Author: Brian Kearns <[email protected]>
Branch:
Changeset: r61998:1bd1b46c3b04
Date: 2013-03-04 04:52 -0500
http://bitbucket.org/pypy/pypy/changeset/1bd1b46c3b04/
Log: whitespace/comments
diff --git a/dotviewer/strunicode.py b/dotviewer/strunicode.py
--- a/dotviewer/strunicode.py
+++ b/dotviewer/strunicode.py
@@ -1,15 +1,17 @@
RAW_ENCODING = "utf-8"
ENCODING_ERROR_HANDLING = "replace"
+
def forceunicode(name):
""" returns `name` as unicode, even if it wasn't before """
return name if isinstance(name, unicode) else name.decode(RAW_ENCODING,
ENCODING_ERROR_HANDLING)
def forcestr(name):
- """ returns `name` as (possibly `RAW_ENCODING` encoded) string, even if it
wasn't before """
+ """ returns `name` as string, even if it wasn't before """
return name if isinstance(name, str) else name.encode(RAW_ENCODING,
ENCODING_ERROR_HANDLING)
+
def tryencode(name):
""" returns `name` as encoded string if it was unicode before """
return name.encode(RAW_ENCODING, ENCODING_ERROR_HANDLING) if
isinstance(name, unicode) else name
diff --git a/dotviewer/test/test_unicode_util.py
b/dotviewer/test/test_unicode_util.py
--- a/dotviewer/test/test_unicode_util.py
+++ b/dotviewer/test/test_unicode_util.py
@@ -57,28 +57,17 @@
assert result
def test_only_unicode_encode(self):
-
sut = [1, u"a", "miau", u"λ"]
- expected = [int, str, str , str ]
+ expected = [int, str, str, str ]
results = map(tryencode, sut)
-
-
for result, expected_type in zip(results, expected):
assert isinstance(result, expected_type)
def test_forceunicode_should_not_fail(self):
-
- garbage = "\xef\xff\xbb\xbf\xce\xbb\xff\xff" # garbage with a lambda
-
- result = forceunicode(garbage)
- assert True, "should not raise"
+ garbage = "\xef\xff\xbb\xbf\xce\xbb\xff\xff" # garbage with a lambda
+ result = forceunicode(garbage) # should not raise
def test_forcestr_should_not_fail(self):
-
- garbage = u"\xef\xff\xbb\xbf\xce\xbb\xff\xff" # garbage
-
- result = forcestr(garbage)
- assert True, "should not raise"
-
-
+ garbage = u"\xef\xff\xbb\xbf\xce\xbb\xff\xff" # garbage
+ result = forcestr(garbage) # should not raise
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit