Better handling of file I/O
Change-Id: I869949b9594cf762989cbf3dfad1bb315bd6cb8e
diff --git a/TestON/tests/SCPFintentEventTp/SCPFintentEventTp.py b/TestON/tests/SCPFintentEventTp/SCPFintentEventTp.py
index b0aeac5..eb581ea 100644
--- a/TestON/tests/SCPFintentEventTp/SCPFintentEventTp.py
+++ b/TestON/tests/SCPFintentEventTp/SCPFintentEventTp.py
@@ -305,17 +305,16 @@
main.ONOSbench.handle.expect(":~")
main.log.info("Stopping intentperf" )
- resultsDB = open("/tmp/IntentEventTPDB", "a")
- for node in groupResult:
-
- resultString = "'" + commit + "',"
- resultString += "'1gig',"
- resultString += str(clusterCount) + ","
- resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
- resultString += n + ","
- resultString += str(node) + ","
- resultString += str(0) + "\n" #no stddev
- resultsDB.write(resultString)
+ with open("/tmp/IntentEventTPDB", "a") as resultsDB:
+ for node in groupResult:
+ resultString = "'" + commit + "',"
+ resultString += "'1gig',"
+ resultString += str(clusterCount) + ","
+ resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
+ resultString += n + ","
+ resultString += str(node) + ","
+ resultString += str(0) + "\n" #no stddev
+ resultsDB.write(resultString)
resultsDB.close()