Commit 8ce213f2 authored by Naoki Kambe's avatar Naoki Kambe
Browse files

[2883] None not acceptable for spec_file_name of the Counters class

Remove condition that spec_file_name is omitted (None is specified). Revise
documentation of Counters and add a unit test to assert an exception raised when
specifying an invalid argument.
parent 0207a121
......@@ -168,19 +168,14 @@ class Counters():
def __init__(self, spec_file_name):
"""A constructor for the Counters class. A path to the spec file
can be specified in spec_file_name, which is required. Statistics data
based on statistics spec can be accumulated if spec_file_name is
specified. If omitted, a default statistics spec is used. The
default statistics spec is defined in a hidden class named
based on statistics spec can be accumulated. If an invalid argument
including None is specified, ModuleSpecError might be raised.
self._zones_item_list = []
self._start_time = {}
self._disabled = False
self._rlock = threading.RLock()
self._statistics_data = {}
self._statistics_spec = []
if not spec_file_name: return
# change the default statistics spec
self._statistics_spec = \
......@@ -154,6 +154,14 @@ class TestBasicMethods(unittest.TestCase):
b = a + ({},)
self.assertRaises(TypeError, counters._concat, *b)
def test_none_of_arg_of_counters(self):
"""Test Counters raises ModuleSpecError when specifying not valid
counters.Counters, None)
counters.Counters, '/foo/bar')
class BaseTestCounters():
def setUp(self):
......@@ -195,18 +203,6 @@ class BaseTestCounters():
self.counters.get, '__undefined__')
class TestCounters0(unittest.TestCase, BaseTestCounters):
def setUp(self):
def test_counters(self):
self.assertRaises(, self.counters.get,
class TestCounters1(unittest.TestCase, BaseTestCounters):
TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec1.spec'
def setUp(self):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment