[tor-commits] [stem/master] Simplify exit status checks

atagar at torproject.org atagar at torproject.org
Thu Jan 23 23:23:35 UTC 2020


commit 2ed4040afc1ef2a64713a2f9e0290c6a821d0bd3
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Jan 23 15:21:25 2020 -0800

    Simplify exit status checks
    
    Nothing important. In python checking for None with 'is' is slightly preferred,
    and I'm unsure why we had separate conditionals for positive and negative exit
    statuses.
---
 test/integ/process.py | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/test/integ/process.py b/test/integ/process.py
index 1a64949e..e26a22c0 100644
--- a/test/integ/process.py
+++ b/test/integ/process.py
@@ -591,14 +591,11 @@ class TestProcess(unittest.TestCase):
       start_time = time.time()
 
       while time.time() - start_time < 30:
-        if tor_process.poll() != None:
-          exitcode = tor_process.returncode
-          if exitcode < 0:
-            raise AssertionError("Tor exited with signal %d"%-exitcode)
-          elif exitcode > 0:
-            raise AssertionError("Tor exited with exit code %d"%exitcode)
+        if tor_process.poll() is not None:
+          if tor_process.returncode != 0:
+            raise AssertionError('Tor exited with a non-zero exit status: %i' % tor_process.returncode)
           else:
-            return  # tor exited without error.
+            return  # tor exited successfully
 
         time.sleep(0.01)
 
@@ -638,14 +635,11 @@ class TestProcess(unittest.TestCase):
       start_time = time.time()
 
       while time.time() - start_time < 20:
-        if tor_process.poll() != None:
-          exitcode = tor_process.returncode
-          if exitcode < 0:
-            raise AssertionError("Tor exited with signal %d"%-exitcode)
-          elif exitcode > 0:
-            raise AssertionError("Tor exited with exit code %d"%exitcode)
+        if tor_process.poll() is not None:
+          if tor_process.returncode != 0:
+            raise AssertionError('Tor exited with a non-zero exit status: %i' % tor_process.returncode)
           else:
-            return  # tor exited without error.
+            return  # tor exited successfully
 
         time.sleep(0.01)
 



More information about the tor-commits mailing list