systematic use of context managers for dealing with files instead of open()/close...
[nepi.git] / test / resources / netns / netnswrapper.py
index 8e33b0c..0fe179f 100755 (executable)
@@ -122,11 +122,11 @@ class NetNSWrapperTest(unittest.TestCase):
             p1 = wrapper.invoke(a1, "poll")
             p2 = wrapper.invoke(a2, "poll")
 
-        stdout1 = open(path1, "r")
-        stdout2 = open(path2, "r")
+        with open(path1, "r") as stdout1:
+            with open(path2, "r") as stdout2:
 
-        s1 = stdout1.read()
-        s2 = stdout2.read()
+                s1 = stdout1.read()
+                s2 = stdout2.read()
 
         expected = "1 packets transmitted, 1 received, 0% packet loss"
         self.assertTrue(s1.find(expected) > -1)