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'
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec1.spec'
 
 
     def setUp(self):
     def setUp(self):
-        imp.reload(counters)
         self.counters = counters.Counters(self.TEST_SPECFILE_LOCATION)
         self.counters = counters.Counters(self.TEST_SPECFILE_LOCATION)
 
 
-    def tearDown(self):
-        self.counters.clear_all()
-
     def test_clear_counters(self):
     def test_clear_counters(self):
         self.assertRaises(isc.cc.data.DataNotFoundError,
         self.assertRaises(isc.cc.data.DataNotFoundError,
                           self.counters.get, 'counter')
                           self.counters.get, 'counter')
@@ -161,13 +157,9 @@ class TestBasicMethods(unittest.TestCase):
 class BaseTestCounters():
 class BaseTestCounters():
 
 
     def setUp(self):
     def setUp(self):
-        imp.reload(counters)
         self._statistics_data = {}
         self._statistics_data = {}
         self.counters = counters.Counters(self.TEST_SPECFILE_LOCATION)
         self.counters = counters.Counters(self.TEST_SPECFILE_LOCATION)
 
 
-    def tearDown(self):
-        self.counters.clear_all()
-
     def check_get_statistics(self):
     def check_get_statistics(self):
         """Checks no differences between the value returned from
         """Checks no differences between the value returned from
         get_statistics() and locally collected statistics data. Also
         get_statistics() and locally collected statistics data. Also
@@ -207,15 +199,11 @@ class TestCounters0(unittest.TestCase, BaseTestCounters):
     TEST_SPECFILE_LOCATION = None
     TEST_SPECFILE_LOCATION = None
     def setUp(self):
     def setUp(self):
         BaseTestCounters.setUp(self)
         BaseTestCounters.setUp(self)
-    def tearDown(self):
-        BaseTestCounters.tearDown(self)
 
 
 class TestCounters1(unittest.TestCase, BaseTestCounters):
 class TestCounters1(unittest.TestCase, BaseTestCounters):
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec1.spec'
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec1.spec'
     def setUp(self):
     def setUp(self):
         BaseTestCounters.setUp(self)
         BaseTestCounters.setUp(self)
-    def tearDown(self):
-        BaseTestCounters.tearDown(self)
 
 
 if __name__== "__main__":
 if __name__== "__main__":
     unittest.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):
 class BaseTestCounters(counters_test.BaseTestCounters):
 
 
     def setUp(self):
     def setUp(self):
-        imp.reload(dns)
         self._statistics_data = {}
         self._statistics_data = {}
         self.counters = dns.Counters(self.TEST_SPECFILE_LOCATION)
         self.counters = dns.Counters(self.TEST_SPECFILE_LOCATION)
         self._entire_server    = self.counters._entire_server
         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'
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec2.spec'
     def setUp(self):
     def setUp(self):
         BaseTestCounters.setUp(self)
         BaseTestCounters.setUp(self)
-    def tearDown(self):
-        BaseTestCounters.tearDown(self)
 
 
 class TestCounters3(unittest.TestCase, BaseTestCounters):
 class TestCounters3(unittest.TestCase, BaseTestCounters):
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec3.spec'
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec3.spec'
     @classmethod
     @classmethod
-    def setUpClass(cls):
-        imp.reload(dns)
     def setUp(self):
     def setUp(self):
         BaseTestCounters.setUp(self)
         BaseTestCounters.setUp(self)
-    def tearDown(self):
-        BaseTestCounters.tearDown(self)
 
 
 class BaseDummyModule():
 class BaseDummyModule():
     """A base dummy class"""
     """A base dummy class"""
@@ -164,9 +157,6 @@ class BaseDummyModule():
     def get_counters(self):
     def get_counters(self):
         return self.counters.get_statistics()
         return self.counters.get_statistics()
 
 
-    def clear_counters(self):
-        self.counters.clear_all()
-
 class DummyNotifyOut(BaseDummyModule):
 class DummyNotifyOut(BaseDummyModule):
     """A dummy class equivalent to notify.notify_out.NotifyOut"""
     """A dummy class equivalent to notify.notify_out.NotifyOut"""
     def inc_counters(self):
     def inc_counters(self):
@@ -213,13 +203,9 @@ class TestDummyXfroutServer(unittest.TestCase):
     """Tests counters are incremented or decremented in which the same
     """Tests counters are incremented or decremented in which the same
     spec file is multiply loaded in each child class"""
     spec file is multiply loaded in each child class"""
     def setUp(self):
     def setUp(self):
-        imp.reload(dns)
         self.xfrout_server = DummyXfroutServer()
         self.xfrout_server = DummyXfroutServer()
         self.xfrout_server.inc_counters()
         self.xfrout_server.inc_counters()
 
 
-    def tearDown(self):
-        self.xfrout_server.clear_counters()
-
     def test_counters(self):
     def test_counters(self):
         self.assertEqual(
         self.assertEqual(
             {'axfr_running': 0, 'ixfr_running': 0,
             {'axfr_running': 0, 'ixfr_running': 0,