BIND 10 trac2225_statistics, updated. ad4eae2bc3410084b4ea07dd96118c7c1da17a25 [2225_statistics] add @staticmethod annotation to inc_notifyoutv4() and inc_notifyoutv6()

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Nov 27 08:43:31 UTC 2012


The branch, trac2225_statistics has been updated
       via  ad4eae2bc3410084b4ea07dd96118c7c1da17a25 (commit)
       via  36df68ce895eefd601857fa5d8e1d701137fe218 (commit)
       via  a9a229b2314c336cf4dd7a257371231530dbae13 (commit)
       via  48625915d6898ddca0eba5b3be512b1dcb29487b (commit)
      from  0a10b2ed25935e83cd0402ae4df81e6d321d75e8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ad4eae2bc3410084b4ea07dd96118c7c1da17a25
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Tue Nov 27 14:58:14 2012 +0900

    [2225_statistics] add @staticmethod annotation to inc_notifyoutv4() and inc_notifyoutv6()

commit 36df68ce895eefd601857fa5d8e1d701137fe218
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Tue Nov 27 16:34:27 2012 +0900

    [2225_statistics] do imp.reload(counter) in setUpClass()

commit a9a229b2314c336cf4dd7a257371231530dbae13
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Tue Nov 27 14:57:37 2012 +0900

    [2225_statistics] change init() to class method (add @classmethod annotation)

commit 48625915d6898ddca0eba5b3be512b1dcb29487b
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Tue Nov 27 15:57:34 2012 +0900

    [2225_statistics] put _COUNTER inside of the class scope

-----------------------------------------------------------------------

Summary of changes:
 src/lib/python/isc/statistics/counter.py           |   22 +++++++++++---------
 .../python/isc/statistics/tests/counter_test.py    |   13 +++++++++++-
 2 files changed, 24 insertions(+), 11 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/statistics/counter.py b/src/lib/python/isc/statistics/counter.py
index 5654542..22b8e4c 100644
--- a/src/lib/python/isc/statistics/counter.py
+++ b/src/lib/python/isc/statistics/counter.py
@@ -73,9 +73,6 @@ import threading
 import isc.config
 from datetime import datetime
 
-# container of a counter object
-_COUNTER = None
-
 # static internal functions
 def _add_counter(element, spec, identifier):
     """Returns value of the identifier if the identifier is in the
@@ -144,25 +141,30 @@ def _stop_timer(start_time, element, spec, identifier):
 
 class Counter():
     """A counter class"""
-    def init(spec_file_name):
+    # container of a counter object
+    _COUNTER = None
+
+    @classmethod
+    def init(cls, spec_file_name):
         """A creator method for a counter class. It creates a counter
         object by the module name of the given spec file. An argument is a
         specification file name."""
-        global _COUNTER
-        if isinstance(_COUNTER, _Counter):
+        if isinstance(cls._COUNTER, _Counter):
             # already loaded
-            return _COUNTER
+            return cls._COUNTER
         # create an instance once
-        _COUNTER = _Counter(spec_file_name)
+        cls._COUNTER = _Counter(spec_file_name)
         # set methods in Counter
-        for (k, v) in _COUNTER._to_global.items():
+        for (k, v) in cls._COUNTER._to_global.items():
             setattr(Counter, k, v)
-        return _COUNTER
+        return cls._COUNTER
 
     # These method are dummies for isc.notify.notify_out.
+    @staticmethod
     def inc_notifyoutv4(arg):
         """An empty method to be disclosed"""
         pass
+    @staticmethod
     def inc_notifyoutv6(arg):
         """An empty method to be disclosed"""
         pass
diff --git a/src/lib/python/isc/statistics/tests/counter_test.py b/src/lib/python/isc/statistics/tests/counter_test.py
index 947bd41..55e59e8 100644
--- a/src/lib/python/isc/statistics/tests/counter_test.py
+++ b/src/lib/python/isc/statistics/tests/counter_test.py
@@ -146,8 +146,10 @@ class TestBasicMethods(unittest.TestCase):
                                  timer_name), 0)
 
 class BaseTestCounter():
-    def setUp(self):
+    @classmethod
+    def setUpClass(cls):
         imp.reload(counter)
+    def setUp(self):
         self._module_spec = isc.config.module_spec_from_file(
             self.TEST_SPECFILE_LOCATION)
         self.counter = counter.Counter.init(self.TEST_SPECFILE_LOCATION)
@@ -324,6 +326,9 @@ class BaseTestCounter():
 
 class TestCounter1(unittest.TestCase, BaseTestCounter):
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec1.spec'
+    @classmethod
+    def setUpClass(cls):
+        BaseTestCounter.setUpClass()
     def setUp(self):
         BaseTestCounter.setUp(self)
     def tearDown(self):
@@ -331,6 +336,9 @@ class TestCounter1(unittest.TestCase, BaseTestCounter):
 
 class TestCounter2(unittest.TestCase, BaseTestCounter):
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec2.spec'
+    @classmethod
+    def setUpClass(cls):
+        BaseTestCounter.setUpClass()
     def setUp(self):
         BaseTestCounter.setUp(self)
     def tearDown(self):
@@ -338,6 +346,9 @@ class TestCounter2(unittest.TestCase, BaseTestCounter):
 
 class TestCounter3(unittest.TestCase, BaseTestCounter):
     TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec3.spec'
+    @classmethod
+    def setUpClass(cls):
+        BaseTestCounter.setUpClass()
     def setUp(self):
         BaseTestCounter.setUp(self)
     def tearDown(self):



More information about the bind10-changes mailing list