diff options
Diffstat (limited to 'test/HeaderGen.py')
-rw-r--r-- | test/HeaderGen.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/test/HeaderGen.py b/test/HeaderGen.py index 2763b34..f66ef57 100644 --- a/test/HeaderGen.py +++ b/test/HeaderGen.py @@ -35,9 +35,8 @@ test = TestSCons.TestSCons() test.write('SConstruct', """\ def writeFile(target, contents): - file = open(str(target[0]), 'w') - file.write(contents) - file.close() + with open(str(target[0]), 'w') as f: + f.write(contents) return 0 env = Environment() @@ -60,10 +59,9 @@ test.write('SConstruct', """\ env = Environment() def gen_a_h(target, source, env): - t = open(str(target[0]), 'w') - s = open(str(source[0]), 'r') - s.readline() - t.write(s.readline()[:-1] + ';\\n') + with open(str(target[0]), 'w') as t, open(str(source[0]), 'r') as s: + s.readline() + t.write(s.readline()[:-1] + ';\\n') MakeHeader = Builder(action = gen_a_h) env_no_scan = env.Clone(SCANNERS=[], BUILDERS={'MakeHeader' : MakeHeader}) |