diff options
author | Gaurav Juvekar <gauravjuvekar@gmail.com> | 2017-05-10 06:37:36 (GMT) |
---|---|---|
committer | Gaurav Juvekar <gauravjuvekar@gmail.com> | 2017-05-10 06:37:36 (GMT) |
commit | 43383ea01595a910c38e28dacb1c84bc690eb236 (patch) | |
tree | 2bf159f7669c263f173a932a513978eaa177b9bb /src/engine | |
parent | 166cd52fd4c2f8ca32966b7669e9caf0ede05a5d (diff) | |
download | SCons-43383ea01595a910c38e28dacb1c84bc690eb236.zip SCons-43383ea01595a910c38e28dacb1c84bc690eb236.tar.gz SCons-43383ea01595a910c38e28dacb1c84bc690eb236.tar.bz2 |
Fix UtilTests to use different IO buffering for py2/3
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/SCons/UtilTests.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 616d419..0d1b7bb 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -186,12 +186,17 @@ class UtilTestCase(unittest.TestCase): try: node, expect, withtags = self.tree_case_1() - sys.stdout = io.StringIO() + if sys.version_info.major < 3: + IOStream = io.BytesIO + else: + IOStream = io.StringIO + + sys.stdout = IOStream() print_tree(node, get_children) actual = sys.stdout.getvalue() assert expect == actual, (expect, actual) - sys.stdout = io.StringIO() + sys.stdout = IOStream() print_tree(node, get_children, showtags=1) actual = sys.stdout.getvalue() assert withtags == actual, (withtags, actual) @@ -200,12 +205,12 @@ class UtilTestCase(unittest.TestCase): # the same as the default (see above) node, expect, withtags = self.tree_case_2(prune=0) - sys.stdout = io.StringIO() + sys.stdout = IOStream() print_tree(node, get_children, 0) actual = sys.stdout.getvalue() assert expect == actual, (expect, actual) - sys.stdout = io.StringIO() + sys.stdout = IOStream() print_tree(node, get_children, 0, showtags=1) actual = sys.stdout.getvalue() assert withtags == actual, (withtags, actual) @@ -213,7 +218,7 @@ class UtilTestCase(unittest.TestCase): # Test output with prune=1 node, expect, withtags = self.tree_case_2(prune=1) - sys.stdout = io.StringIO() + sys.stdout = IOStream() print_tree(node, get_children, 1) actual = sys.stdout.getvalue() assert expect == actual, (expect, actual) @@ -222,12 +227,12 @@ class UtilTestCase(unittest.TestCase): # again. This wasn't possible in version 2.4.1 and earlier # due to a bug in print_tree (visited was set to {} as default # parameter) - sys.stdout = io.StringIO() + sys.stdout = IOStream() print_tree(node, get_children, 1) actual = sys.stdout.getvalue() assert expect == actual, (expect, actual) - sys.stdout = io.StringIO() + sys.stdout = IOStream() print_tree(node, get_children, 1, showtags=1) actual = sys.stdout.getvalue() assert withtags == actual, (withtags, actual) |