Skip to content

Commit 79e5acf

Browse files
committed
[test/validation_init] Fix Win stdout redirect
Windows does not support fetching the systems stdout via the 'sys.__stdout__' magic method in all cases.
1 parent e04387d commit 79e5acf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/test_validation_integration.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ class TestValidationIntegration(unittest.TestCase):
1717

1818
def setUp(self):
1919
# Redirect stdout to test messages
20+
self.stdout_orig = sys.stdout
2021
self.capture = StringIO()
2122
sys.stdout = self.capture
2223

2324
self.msg_base = "Property values cardinality violated"
2425

2526
def tearDown(self):
26-
# Reset stdout
27-
sys.stdout = sys.__stdout__
27+
# Reset stdout; resetting using 'sys.__stdout__' fails on windows
28+
sys.stdout = self.stdout_orig
29+
self.capture.close()
2830

2931
def _get_captured_output(self):
3032
out = [txt.strip() for txt in self.capture.getvalue().split('\n') if txt]

0 commit comments

Comments
 (0)