X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=test%2Fresources%2Fomf%2Fomf6_vlc_traces.py;h=c9ab328a1875e671e7c591dc23623d0f574efad8;hb=cb5d027b813a27d7de263653e1a8e0cef5490f0a;hp=65ce2157fa003a18649c3a1d8844462d531562f3;hpb=741b99fe027fe6b54846a0703d26510d9b40a135;p=nepi.git diff --git a/test/resources/omf/omf6_vlc_traces.py b/test/resources/omf/omf6_vlc_traces.py index 65ce2157..c9ab328a 100755 --- a/test/resources/omf/omf6_vlc_traces.py +++ b/test/resources/omf/omf6_vlc_traces.py @@ -4,9 +4,8 @@ # Copyright (C) 2013 INRIA # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation; # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -77,14 +76,12 @@ class OMFPingNormalCase(unittest.TestCase): stderr_1 = ec.trace(self.app1, "stderr") if stdout_1: - f = open("app1_out.txt", "w") - f.write(stdout_1) - f.close() + with open("app1_out.txt", "w") as f: + f.write(stdout_1) if stderr_1: - f = open("app1_err.txt", "w") - f.write(stderr_1) - f.close() + with open("app1_err.txt", "w") as f: + f.write(stderr_1) self.assertEquals(ec.get_resource(self.node1).state, ResourceState.STARTED) self.assertEquals(ec.get_resource(self.iface1).state, ResourceState.STARTED) @@ -98,13 +95,12 @@ class OMFPingNormalCase(unittest.TestCase): self.assertEquals(ec.get_resource(self.channel).state, ResourceState.RELEASED) self.assertEquals(ec.get_resource(self.app1).state, ResourceState.RELEASED) - t = open("app1_out.txt", "r") - l = t.readlines() - self.assertEquals(l[0], "PING 10.0.0.17 (10.0.0.17) 56(84) bytes of data.\n") - self.assertIn("5 packets transmitted, 5 received, 0% packet loss, time", l[-2]) - self.assertIn("rtt min/avg/max/mdev = ", l[-1]) + with open("app1_out.txt", "r") as t: + l = t.readlines() + self.assertEquals(l[0], "PING 10.0.0.17 (10.0.0.17) 56(84) bytes of data.\n") + self.assertIn("5 packets transmitted, 5 received, 0% packet loss, time", l[-2]) + self.assertIn("rtt min/avg/max/mdev = ", l[-1]) - t.close() os.remove("app1_out.txt")