[tor-commits] [stem/master] Only checking cached descriptor existance when needed
atagar at torproject.org
atagar at torproject.org
Mon May 14 00:14:27 UTC 2012
commit 9d24a9090a00a8686b6eae3258bb6af84cd06087
Author: Damian Johnson <atagar at torproject.org>
Date: Wed May 9 09:11:46 2012 -0700
Only checking cached descriptor existance when needed
Maybe once upon a time we had multiple tests that ran over the cached
descriptors? I don't recall it, and we definitely don't right now so only
checking for the existance of the cached-descriptor and cached-extrainfo files
when we want to test against them.
---
test/integ/descriptor/extrainfo_descriptor.py | 21 ++++-----------------
test/integ/descriptor/server_descriptor.py | 22 ++++------------------
2 files changed, 8 insertions(+), 35 deletions(-)
diff --git a/test/integ/descriptor/extrainfo_descriptor.py b/test/integ/descriptor/extrainfo_descriptor.py
index ec94d7c..d62a164 100644
--- a/test/integ/descriptor/extrainfo_descriptor.py
+++ b/test/integ/descriptor/extrainfo_descriptor.py
@@ -10,19 +10,9 @@ import stem.descriptor.extrainfo_descriptor
import test.runner
import test.integ.descriptor
-# 'test_cached_descriptor' is a lengthy test and uneffected by testing targets,
-# so including a flag to prevent it from being ran multiple times
-
RAN_CACHED_DESCRIPTOR_TEST = False
class TestExtraInfoDescriptor(unittest.TestCase):
- is_cached_descriptors_available = None
-
- def setUp(self):
- if self.is_cached_descriptors_available is None:
- descriptor_path = test.runner.get_runner().get_test_dir("cached-extrainfo")
- self.is_cached_descriptors_available = os.path.exists(descriptor_path)
-
def test_metrics_descriptor(self):
"""
Parses and checks our results against an extrainfo descriptor from metrics.
@@ -75,18 +65,15 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
additions.
"""
- descriptor_path = test.runner.get_runner().get_test_dir("cached-extrainfo")
-
- if not self.is_cached_descriptors_available:
- self.skipTest("(no cached descriptors)")
-
global RAN_CACHED_DESCRIPTOR_TEST
+ descriptor_path = test.runner.get_runner().get_test_dir("cached-extrainfo")
if RAN_CACHED_DESCRIPTOR_TEST:
self.skipTest("(already ran)")
- else:
- RAN_CACHED_DESCRIPTOR_TEST = True
+ elif not os.path.exists(descriptor_path):
+ self.skipTest("(no cached descriptors)")
+ RAN_CACHED_DESCRIPTOR_TEST = True
with open(descriptor_path) as descriptor_file:
for desc in stem.descriptor.extrainfo_descriptor.parse_file(descriptor_file):
# TODO: uncomment when we're done implementing the ExtraInfoDescriptor class
diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py
index b43d1ee..57f6879 100644
--- a/test/integ/descriptor/server_descriptor.py
+++ b/test/integ/descriptor/server_descriptor.py
@@ -18,17 +18,6 @@ import test.integ.descriptor
RAN_CACHED_DESCRIPTOR_TEST = False
class TestServerDescriptor(unittest.TestCase):
- is_cached_descriptors_available = None
-
- def setUp(self):
- # If this is our first time running the integ tests and we didn't wait for
- # a full tor initialization then the cached descriptors won't exist yet.
- # Noting if they exist or not since some tests need them.
-
- if self.is_cached_descriptors_available is None:
- descriptor_path = test.runner.get_runner().get_test_dir("cached-descriptors")
- self.is_cached_descriptors_available = os.path.exists(descriptor_path)
-
def test_metrics_descriptor(self):
"""
Parses and checks our results against a server descriptor from metrics.
@@ -163,18 +152,15 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
additions.
"""
- descriptor_path = test.runner.get_runner().get_test_dir("cached-descriptors")
-
- if not self.is_cached_descriptors_available:
- self.skipTest("(no cached descriptors)")
-
global RAN_CACHED_DESCRIPTOR_TEST
+ descriptor_path = test.runner.get_runner().get_test_dir("cached-descriptors")
if RAN_CACHED_DESCRIPTOR_TEST:
self.skipTest("(already ran)")
- else:
- RAN_CACHED_DESCRIPTOR_TEST = True
+ elif not os.path.exists(descriptor_path):
+ self.skipTest("(no cached descriptors)")
+ RAN_CACHED_DESCRIPTOR_TEST = True
with open(descriptor_path) as descriptor_file:
for desc in stem.descriptor.server_descriptor.parse_file(descriptor_file):
# the following attributes should be deprecated, and not appear in the wild
More information about the tor-commits
mailing list