Nir Soffer has uploaded a new change for review.

Change subject: tests: Use Popen.poll() for running state
......................................................................

tests: Use Popen.poll() for running state

Checking if /proc/pid exists works, but using poll() is simpler and more
clear.

Since proc_path is used only in one test, move it the test using it.

Change-Id: I086e9317b5f8e5324d86bedeb04b485c7a09ad16
Signed-off-by: Nir Soffer <nsof...@redhat.com>
---
M tests/utilsTests.py
1 file changed, 5 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/65323/1

diff --git a/tests/utilsTests.py b/tests/utilsTests.py
index d8bc628..388a65d 100644
--- a/tests/utilsTests.py
+++ b/tests/utilsTests.py
@@ -97,9 +97,7 @@
 
     def setUp(self):
         self.proc = commands.execCmd([EXT_SLEEP, "2"], sync=False)
-        self.proc_path = "/proc/%d" % self.proc.pid
         self.kill_proc = self.proc.kill
-        self.assertTrue(os.path.exists(self.proc_path))
         self.reaped = set()
 
     def tearDown(self):
@@ -109,8 +107,9 @@
 
     def test_terminating(self):
         with utils.terminating(self.proc):
-            self.assertTrue(os.path.exists(self.proc_path))
-        self.assertTrue(wait_for_removal(self.proc_path, timeout=1))
+            self.assertIsNone(self.proc.poll())
+        proc_path = "/proc/%d" % self.proc.pid
+        self.assertTrue(wait_for_removal(proc_path, timeout=1))
 
     def test_terminating_with_kill_exception(self):
         class FakeKillError(Exception):
@@ -125,7 +124,7 @@
                                 )]):
             self.proc.kill = fake_kill
             with utils.terminating(self.proc):
-                self.assertTrue(os.path.exists(self.proc_path))
+                self.assertIsNone(self.proc.poll())
             self.assertTrue(self.proc.pid not in self.reaped)
 
     def test_terminating_with_infected_kill(self):
@@ -135,7 +134,7 @@
                                 )]):
             self.proc.kill = lambda: None
             with utils.terminating(self.proc):
-                self.assertTrue(os.path.exists(self.proc_path))
+                self.assertIsNone(self.proc.poll())
             self.assertTrue(self.proc.pid in self.reaped)
 
 


-- 
To view, visit https://gerrit.ovirt.org/65323
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I086e9317b5f8e5324d86bedeb04b485c7a09ad16
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsof...@redhat.com>
_______________________________________________
vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org
To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org

Reply via email to