[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Drop hardcoded test name from test.runner.only_run_once()



commit 58ffa279eaa7e0961ee93329120663a11eec5d72
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Feb 16 17:43:17 2015 -0800

    Drop hardcoded test name from test.runner.only_run_once()
    
    On reflection we can get a sentinel from unittest's id() method...
    
      https://docs.python.org/2/library/unittest.html#unittest.TestCase.id
---
 test/integ/descriptor/extrainfo_descriptor.py |    2 +-
 test/integ/descriptor/microdescriptor.py      |    2 +-
 test/integ/descriptor/networkstatus.py        |    4 ++--
 test/integ/descriptor/remote.py               |   14 +++++++-------
 test/integ/descriptor/server_descriptor.py    |    2 +-
 test/integ/process.py                         |   10 +++++-----
 test/runner.py                                |    7 +++----
 7 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/test/integ/descriptor/extrainfo_descriptor.py b/test/integ/descriptor/extrainfo_descriptor.py
index 5a81d81..cfbc1e5 100644
--- a/test/integ/descriptor/extrainfo_descriptor.py
+++ b/test/integ/descriptor/extrainfo_descriptor.py
@@ -19,7 +19,7 @@ class TestExtraInfoDescriptor(unittest.TestCase):
 
     # lengthy test and uneffected by targets, so only run once
 
-    if test.runner.only_run_once(self, 'test_cached_descriptor'):
+    if test.runner.only_run_once(self):
       return
 
     descriptor_path = test.runner.get_runner().get_test_dir('cached-extrainfo')
diff --git a/test/integ/descriptor/microdescriptor.py b/test/integ/descriptor/microdescriptor.py
index 9849e26..0652587 100644
--- a/test/integ/descriptor/microdescriptor.py
+++ b/test/integ/descriptor/microdescriptor.py
@@ -17,7 +17,7 @@ class TestMicrodescriptor(unittest.TestCase):
     descriptor additions.
     """
 
-    if test.runner.only_run_once(self, 'test_cached_microdescriptors'):
+    if test.runner.only_run_once(self):
       return
 
     descriptor_path = test.runner.get_runner().get_test_dir('cached-microdescs')
diff --git a/test/integ/descriptor/networkstatus.py b/test/integ/descriptor/networkstatus.py
index 032f83c..6c29158 100644
--- a/test/integ/descriptor/networkstatus.py
+++ b/test/integ/descriptor/networkstatus.py
@@ -20,7 +20,7 @@ class TestNetworkStatus(unittest.TestCase):
 
     # lengthy test and uneffected by targets, so only run once
 
-    if test.runner.only_run_once(self, 'test_cached_consensus'):
+    if test.runner.only_run_once(self):
       return
 
     consensus_path = test.runner.get_runner().get_test_dir('cached-consensus')
@@ -64,7 +64,7 @@ class TestNetworkStatus(unittest.TestCase):
 
     # lengthy test and uneffected by targets, so only run once
 
-    if test.runner.only_run_once(self, 'test_cached_microdesc_consensus'):
+    if test.runner.only_run_once(self):
       return
 
     consensus_path = test.runner.get_runner().get_test_dir('cached-microdesc-consensus')
diff --git a/test/integ/descriptor/remote.py b/test/integ/descriptor/remote.py
index 5ac848a..9183c0d 100644
--- a/test/integ/descriptor/remote.py
+++ b/test/integ/descriptor/remote.py
@@ -26,7 +26,7 @@ class TestDescriptorDownloader(unittest.TestCase):
 
     if test.runner.require_online(self):
       return
-    elif test.runner.only_run_once(self, 'test_using_authorities'):
+    elif test.runner.only_run_once(self):
       return
 
     queries = []
@@ -56,7 +56,7 @@ class TestDescriptorDownloader(unittest.TestCase):
 
     if test.runner.require_online(self):
       return
-    elif test.runner.only_run_once(self, 'test_use_directory_mirrors'):
+    elif test.runner.only_run_once(self):
       return
 
     downloader = stem.descriptor.remote.DescriptorDownloader()
@@ -70,7 +70,7 @@ class TestDescriptorDownloader(unittest.TestCase):
 
     if test.runner.require_online(self):
       return
-    elif test.runner.only_run_once(self, 'test_get_server_descriptors'):
+    elif test.runner.only_run_once(self):
       return
 
     downloader = stem.descriptor.remote.DescriptorDownloader(validate = True)
@@ -106,7 +106,7 @@ class TestDescriptorDownloader(unittest.TestCase):
 
     if test.runner.require_online(self):
       return
-    elif test.runner.only_run_once(self, 'test_get_extrainfo_descriptors'):
+    elif test.runner.only_run_once(self):
       return
 
     downloader = stem.descriptor.remote.DescriptorDownloader(validate = True)
@@ -140,7 +140,7 @@ class TestDescriptorDownloader(unittest.TestCase):
 
     if test.runner.require_online(self):
       return
-    elif test.runner.only_run_once(self, 'test_get_microdescriptors'):
+    elif test.runner.only_run_once(self):
       return
 
     downloader = stem.descriptor.remote.DescriptorDownloader(validate = True)
@@ -169,7 +169,7 @@ class TestDescriptorDownloader(unittest.TestCase):
 
     if test.runner.require_online(self):
       return
-    elif test.runner.only_run_once(self, 'test_get_consensus'):
+    elif test.runner.only_run_once(self):
       return
 
     downloader = stem.descriptor.remote.DescriptorDownloader(validate = True)
@@ -188,7 +188,7 @@ class TestDescriptorDownloader(unittest.TestCase):
 
     if test.runner.require_online(self):
       return
-    elif test.runner.only_run_once(self, 'test_get_key_certificates'):
+    elif test.runner.only_run_once(self):
       return
 
     downloader = stem.descriptor.remote.DescriptorDownloader(validate = True)
diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py
index 9f018e7..87eba5c 100644
--- a/test/integ/descriptor/server_descriptor.py
+++ b/test/integ/descriptor/server_descriptor.py
@@ -20,7 +20,7 @@ class TestServerDescriptor(unittest.TestCase):
 
     # lengthy test and uneffected by targets, so only run once
 
-    if test.runner.only_run_once(self, 'test_cached_descriptor'):
+    if test.runner.only_run_once(self):
       return
 
     descriptor_path = test.runner.get_runner().get_test_dir('cached-descriptors')
diff --git a/test/integ/process.py b/test/integ/process.py
index b935d46..ca76a5e 100644
--- a/test/integ/process.py
+++ b/test/integ/process.py
@@ -252,7 +252,7 @@ class TestProcess(unittest.TestCase):
     Exercises launch_tor_with_config.
     """
 
-    if test.runner.only_run_once(self, 'test_launch_tor_with_config'):
+    if test.runner.only_run_once(self):
       return
 
     # Launch tor without a torrc, but with a control port. Confirms that this
@@ -290,7 +290,7 @@ class TestProcess(unittest.TestCase):
     Spawn a tor process with a configuration that should make it dead on arrival.
     """
 
-    if test.runner.only_run_once(self, 'test_with_invalid_config'):
+    if test.runner.only_run_once(self):
       return
 
     # Set the same SocksPort and ControlPort, this should fail with...
@@ -316,7 +316,7 @@ class TestProcess(unittest.TestCase):
     Runs launch_tor where it times out before completing.
     """
 
-    if test.runner.only_run_once(self, 'test_launch_tor_with_timeout'):
+    if test.runner.only_run_once(self):
       return
 
     runner = test.runner.get_runner()
@@ -338,7 +338,7 @@ class TestProcess(unittest.TestCase):
     if not stem.util.system.is_available('sleep'):
       test.runner.skip(self, "('sleep' command is unavailable)")
       return
-    elif test.runner.only_run_once(self, 'test_take_ownership_via_pid'):
+    elif test.runner.only_run_once(self):
       return
     elif test.runner.require_version(self, stem.version.Requirement.TAKEOWNERSHIP):
       return
@@ -379,7 +379,7 @@ class TestProcess(unittest.TestCase):
     connects, then disconnects..
     """
 
-    if test.runner.only_run_once(self, 'test_take_ownership_via_controller'):
+    if test.runner.only_run_once(self):
       return
     elif test.runner.require_version(self, stem.version.Requirement.TAKEOWNERSHIP):
       return
diff --git a/test/runner.py b/test/runner.py
index d297241..3d0e43b 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -161,23 +161,22 @@ def require_online(test_case):
     return True
 
 
-def only_run_once(test_case, test_name):
+def only_run_once(test_case):
   """
   Skips the test if it has ran before. If it hasn't then flags it as being ran.
   This is useful to prevent lengthy tests that are independent of integ targets
   from being run repeatedly with ``RUN_ALL``.
 
   :param unittest.TestCase test_case: test being ran
-  :param str test_name: name of the test being ran
 
   :returns: True if test should be skipped, False otherwise
   """
 
-  if (test_case, test_name) in RAN_TESTS:
+  if (test_case, test_case.id()) in RAN_TESTS:
     skip(test_case, '(already ran)')
     return True
   else:
-    RAN_TESTS.append((test_case, test_name))
+    RAN_TESTS.append((test_case, test_case.id()))
 
 
 def exercise_controller(test_case, controller):

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits