Skip to content

Commit be7da21

Browse files
author
Johnny Chen
committed
Convert two instances of assertTrue() and string matching usages to self.expect()
which is more descriptive. And wrap the file open operation inside a with block so that close() is automatically called upon exiting the block. llvm-svn: 116096
1 parent af8b487 commit be7da21

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lldb/test/settings/TestSettings.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ def pass_run_args_and_env_vars(self):
7272
# Read the output file produced by running the program.
7373
output = open('output.txt', 'r').read()
7474

75-
self.assertTrue(output.startswith("argv[1] matches") and
76-
output.find("argv[2] matches") > 0 and
77-
output.find("argv[3] matches") > 0 and
78-
output.find("Environment variable 'MY_ENV_VAR' successfully passed.") > 0)
75+
self.expect(output, exe=False,
76+
substrs = ["argv[1] matches",
77+
"argv[2] matches",
78+
"argv[3] matches",
79+
"Environment variable 'MY_ENV_VAR' successfully passed."])
7980

8081
@unittest2.expectedFailure
8182
# rdar://problem/8435794
@@ -95,10 +96,11 @@ def test_set_output_path(self):
9596
self.runCmd("run", RUN_SUCCEEDED)
9697

9798
# Read the output file produced by running the program.
98-
output = open('stdout.txt', 'r').read()
99+
with open('stdout.txt', 'r') as f:
100+
output = f.read()
99101

100-
self.assertTrue(
101-
output.startswith("This message should go to standard out."))
102+
self.expect(output, exe=False,
103+
startstr = "This message should go to standard out.")
102104

103105

104106
if __name__ == '__main__':

0 commit comments

Comments
 (0)