Skip to content

Commit cdf0e1a

Browse files
committed
Correcting stdout issue with tests
1 parent 21b0496 commit cdf0e1a

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ jobs:
112112
architecture: x64
113113
-
114114
script: 'python setup.py sdist'
115-
displayName: 'Build sdist'
115+
displayName: 'Build sdist'

legacy/mbed-greentea/test/mbed_gt_cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ def test_get_greentea_version(self):
7474
def test_print_version(self):
7575
version = mbed_greentea_cli.get_greentea_version()
7676

77+
old_stdout = sys.stdout
7778
sys.stdout = stdout_capture = six.StringIO()
7879
mbed_greentea_cli.print_version()
79-
sys.stdout = sys.__stdout__
80+
sys.stdout = old_stdout
8081

8182
printed_version = stdout_capture.getvalue().splitlines()[0]
8283
self.assertEqual(printed_version, version)

legacy/mbed-greentea/test/mbed_gt_cmake_handlers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ def test_list_binaries_for_targets(self):
100100
full_path = os.path.join(root_path, "resources")
101101

102102
def run_and_capture(path, verbose=False):
103+
old_stdout = sys.stdout
103104
sys.stdout = stdout_capture = six.StringIO()
104105
cmake_handlers.list_binaries_for_targets(build_dir=path, verbose_footer=verbose)
105-
sys.stdout = sys.__stdout__
106+
sys.stdout = old_stdout
106107

107108
return stdout_capture.getvalue()
108109

@@ -128,9 +129,10 @@ def test_list_binaries_for_builds(self):
128129

129130
for verbose in [True, False]:
130131
# Capture logging output
132+
old_stdout = sys.stdout
131133
sys.stdout = stdout_capture = six.StringIO()
132134
cmake_handlers.list_binaries_for_builds(spec, verbose_footer=verbose)
133-
sys.stdout = sys.__stdout__
135+
sys.stdout = old_stdout
134136

135137
output = stdout_capture.getvalue()
136138
self.assertTrue("available tests for build 'K64F-ARM'" in output)

legacy/mbed-greentea/test/mbed_gt_report_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ def test_export_to_file(self):
105105
payload = "PAYLOAD"
106106
filepath = "."
107107

108+
old_stdout = sys.stdout
108109
sys.stdout = stdout_capture = six.StringIO()
109110
result = mbed_report_api.export_to_file(filepath, payload)
110-
sys.stdout = sys.__stdout__
111+
sys.stdout = old_stdout
111112

112113
command_output = stdout_capture.getvalue().splitlines()[0]
113114
self.assertIn("file failed:", command_output)

test/test/mbed_gt_cmake_handlers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ def test_list_binaries_for_targets(self):
9898
full_path = os.path.join(root_path, "resources")
9999

100100
def run_and_capture(path, verbose=False):
101+
old_stdout = sys.stdout
101102
sys.stdout = stdout_capture = six.StringIO()
102103
cmake_handlers.list_binaries_for_targets(build_dir=path, verbose_footer=verbose)
103-
sys.stdout = sys.__stdout__
104+
sys.stdout = old_stdout
104105

105106
return stdout_capture.getvalue()
106107

@@ -126,9 +127,10 @@ def test_list_binaries_for_builds(self):
126127

127128
for verbose in [True, False]:
128129
# Capture logging output
130+
old_stdout = sys.stdout
129131
sys.stdout = stdout_capture = six.StringIO()
130132
cmake_handlers.list_binaries_for_builds(spec, verbose_footer=verbose)
131-
sys.stdout = sys.__stdout__
133+
sys.stdout = old_stdout
132134

133135
output = stdout_capture.getvalue()
134136
self.assertTrue("available tests for build 'K64F-ARM'" in output)

test/test/mbed_gt_report_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ def test_export_to_file(self):
106106
payload = "PAYLOAD"
107107
filepath = "."
108108

109+
old_stdout = sys.stdout
109110
sys.stdout = stdout_capture = six.StringIO()
110111
result = mbed_report_api.export_to_file(filepath, payload)
111-
sys.stdout = sys.__stdout__
112+
sys.stdout = old_stdout
112113

113114
command_output = stdout_capture.getvalue().splitlines()[0]
114115
self.assertIn("file failed:", command_output)

0 commit comments

Comments
 (0)