Browse Source

[2883] no need to reload module and do tearDown in test classes

The counters object doesn't have a static statistics object
Naoki Kambe 11 years ago
parent
commit
81c1c17fd5

+ 0 - 12
src/lib/python/isc/statistics/tests/counters_test.py

@@ -49,12 +49,8 @@ class TestBasicMethods(unittest.TestCase):
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec1.spec'
 
     def setUp(self):
-        imp.reload(counters)
         self.counters = counters.Counters(self.TEST_SPECFILE_LOCATION)
 
-    def tearDown(self):
-        self.counters.clear_all()
-
     def test_clear_counters(self):
         self.assertRaises(isc.cc.data.DataNotFoundError,
                           self.counters.get, 'counter')
@@ -161,13 +157,9 @@ class TestBasicMethods(unittest.TestCase):
 class BaseTestCounters():
 
     def setUp(self):
-        imp.reload(counters)
         self._statistics_data = {}
         self.counters = counters.Counters(self.TEST_SPECFILE_LOCATION)
 
-    def tearDown(self):
-        self.counters.clear_all()
-
     def check_get_statistics(self):
         """Checks no differences between the value returned from
         get_statistics() and locally collected statistics data. Also
@@ -207,15 +199,11 @@ class TestCounters0(unittest.TestCase, BaseTestCounters):
     TEST_SPECFILE_LOCATION = None
     def setUp(self):
         BaseTestCounters.setUp(self)
-    def tearDown(self):
-        BaseTestCounters.tearDown(self)
 
 class TestCounters1(unittest.TestCase, BaseTestCounters):
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec1.spec'
     def setUp(self):
         BaseTestCounters.setUp(self)
-    def tearDown(self):
-        BaseTestCounters.tearDown(self)
 
 if __name__== "__main__":
     unittest.main()

+ 0 - 14
src/lib/python/isc/statistics/tests/dns_test.py

@@ -30,7 +30,6 @@ from isc.statistics import dns
 class BaseTestCounters(counters_test.BaseTestCounters):
 
     def setUp(self):
-        imp.reload(dns)
         self._statistics_data = {}
         self.counters = dns.Counters(self.TEST_SPECFILE_LOCATION)
         self._entire_server    = self.counters._entire_server
@@ -142,18 +141,12 @@ class TestCounters2(unittest.TestCase, BaseTestCounters):
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec2.spec'
     def setUp(self):
         BaseTestCounters.setUp(self)
-    def tearDown(self):
-        BaseTestCounters.tearDown(self)
 
 class TestCounters3(unittest.TestCase, BaseTestCounters):
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec3.spec'
     @classmethod
-    def setUpClass(cls):
-        imp.reload(dns)
     def setUp(self):
         BaseTestCounters.setUp(self)
-    def tearDown(self):
-        BaseTestCounters.tearDown(self)
 
 class BaseDummyModule():
     """A base dummy class"""
@@ -164,9 +157,6 @@ class BaseDummyModule():
     def get_counters(self):
         return self.counters.get_statistics()
 
-    def clear_counters(self):
-        self.counters.clear_all()
-
 class DummyNotifyOut(BaseDummyModule):
     """A dummy class equivalent to notify.notify_out.NotifyOut"""
     def inc_counters(self):
@@ -213,13 +203,9 @@ class TestDummyXfroutServer(unittest.TestCase):
     """Tests counters are incremented or decremented in which the same
     spec file is multiply loaded in each child class"""
     def setUp(self):
-        imp.reload(dns)
         self.xfrout_server = DummyXfroutServer()
         self.xfrout_server.inc_counters()
 
-    def tearDown(self):
-        self.xfrout_server.clear_counters()
-
     def test_counters(self):
         self.assertEqual(
             {'axfr_running': 0, 'ixfr_running': 0,