fix for Python 2

main
Fabien C. Y. Benureau 6 years ago
parent 31a909eed5
commit 6865e29d15
No known key found for this signature in database
GPG Key ID: C3FB5E831A249A9A

2
.gitignore vendored

@ -1,7 +1,7 @@
.python-version .python-version
*~ *~
.DS_Store .DS_Store
.eggs
*.py[cod] *.py[cod]

@ -98,6 +98,14 @@ class CommandTestCase(fake_env.TestFakeFs):
3. the expected output on stdout, verified with assertEqual. 3. the expected output on stdout, verified with assertEqual.
4. the expected output on stderr, verified with assertEqual. 4. the expected output on stderr, verified with assertEqual.
""" """
def normalize(s):
s = color.undye(s)
try:
s = s.decode('utf-8')
except AttributeError:
pass
return s
try: try:
outs = [] outs = []
for cmd in cmds: for cmd in cmds:
@ -122,8 +130,8 @@ class CommandTestCase(fake_env.TestFakeFs):
capture_wrap = fake_env.capture(pubs_cmd.execute, capture_wrap = fake_env.capture(pubs_cmd.execute,
verbose=PRINT_OUTPUT) verbose=PRINT_OUTPUT)
_, stdout, stderr = capture_wrap(actual_cmd.split()) _, stdout, stderr = capture_wrap(actual_cmd.split())
actual_out = color.undye(stdout) actual_out = normalize(stdout)
actual_err = color.undye(stderr) actual_err = normalize(stderr)
if expected_out is not None: if expected_out is not None:
self.assertEqual(p3.u_maybe(actual_out), p3.u_maybe(expected_out)) self.assertEqual(p3.u_maybe(actual_out), p3.u_maybe(expected_out))
if expected_err is not None: if expected_err is not None:

Loading…
Cancel
Save