From: Cédric Ollivier Date: Mon, 22 Aug 2016 11:40:34 +0000 (+0200) Subject: Avoid opening tmp files twice X-Git-Tag: colorado.1.0~109^2 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=2a8caf0838fe1bbb8d6527a4ec388fa06e24494d;p=functest.git Avoid opening tmp files twice It avoids opening stdout.txt twice and removes it at the end. Change-Id: I7e006b52f49dd32543676259e0a1be2473670487 Signed-off-by: Cédric Ollivier --- diff --git a/testcases/Controllers/ODL/OpenDaylightTesting.py b/testcases/Controllers/ODL/OpenDaylightTesting.py index 2075d13a8..184cacf81 100755 --- a/testcases/Controllers/ODL/OpenDaylightTesting.py +++ b/testcases/Controllers/ODL/OpenDaylightTesting.py @@ -104,15 +104,19 @@ class ODLTestCases: except OSError: pass stdout_file = cls.res_dir + 'stdout.txt' - with open(stdout_file, 'w') as stdout: + with open(stdout_file, 'w+') as stdout: run(*dirs, variable=variables, output=cls.res_dir + 'output.xml', log='NONE', report='NONE', stdout=stdout) - with open(stdout_file, 'r') as stdout: + stdout.seek(0, 0) cls.logger.info("\n" + stdout.read()) cls.logger.info("ODL results was sucessfully generated") + try: + os.remove(stdout_file) + except OSError: + pass return True else: return False