Skip to content

Commit

Permalink
enhancement: add checks if loaded configurations are not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ssato committed Mar 8, 2017
1 parent ee3b607 commit cd30fcd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/backend/common.py
Expand Up @@ -71,21 +71,25 @@ def test_10_loads(self):
def test_12_loads_with_options(self):
if self.is_ready():
cnf = self.psr.loads(self.cnf_s, **self.load_options)
self.assertTrue(cnf)
self._assert_dicts_equal(cnf)

def test_14_loads_with_invalid_options(self):
if self.is_ready():
cnf = self.psr.loads(self.cnf_s, not_exist_option_a=True)
self.assertTrue(cnf)
self._assert_dicts_equal(cnf)

def test_16_loads_with_ac_ordered_option(self):
if self.is_ready():
cnf = self.psr.loads(self.cnf_s, ac_ordered=True)
self.assertTrue(cnf)
self._assert_dicts_equal(cnf, ordered=self.psr.ordered())

def test_18_loads_with_ac_dict_option(self):
if self.is_ready():
cnf = self.psr.loads(self.cnf_s, ac_dict=MyDict)
self.assertTrue(cnf)
self._assert_dicts_equal(cnf, cls=MyDict)
# for debug:
# raise RuntimeError("psr=%r, cnf=%r" % (self.psr, self.cnf))
Expand All @@ -96,13 +100,15 @@ def test_20_loads_with_dict_option(self):
if dopts:
opts = {dopts[0]: MyDict}
cnf = self.psr.loads(self.cnf_s, **opts)
self.assertTrue(cnf)
self._assert_dicts_equal(cnf, cls=MyDict)

def test_30_dumps(self):
if self.is_ready():
cnf_s = self.psr.dumps(self.cnf)
self.assertTrue(cnf_s) # Check if it's not empty.
cnf = self.psr.loads(cnf_s)
self.assertTrue(cnf)
self._assert_dicts_equal(cnf)

def test_32_dumps_with_options(self):
Expand Down Expand Up @@ -135,29 +141,34 @@ class Test_20_dump_and_load(TestBaseWithIO):
def test_10_load(self):
if self.is_ready():
cnf = self.psr.load(self.cnf_path)
self.assertTrue(cnf)
self._assert_dicts_equal(cnf)

def test_12_load_from_stream(self):
if self.is_ready():
with self.psr.ropen(self.cnf_path) as strm:
cnf = self.psr.load(strm)

self.assertTrue(cnf)
self._assert_dicts_equal(cnf)

def test_14_load_with_ac_ordered_option(self):
if self.is_ready():
cnf = self.psr.load(self.cnf_path, ac_ordered=True)
self.assertTrue(cnf)
self._assert_dicts_equal(cnf, ordered=self.psr.ordered())

def test_16_load_with_ac_dict_option(self):
if self.is_ready():
cnf = self.psr.load(self.cnf_path, ac_dict=MyDict)
self.assertTrue(cnf)
self._assert_dicts_equal(cnf, cls=MyDict)

def test_30_dump(self):
if self.is_ready():
self.psr.dump(self.cnf, self.cnf_path)
cnf = self.psr.load(self.cnf_path)
self.assertTrue(cnf)
self._assert_dicts_equal(cnf)

def test_32_dump_to_stream(self):
Expand All @@ -166,6 +177,7 @@ def test_32_dump_to_stream(self):
self.psr.dump(self.cnf, strm)

cnf = self.psr.load(self.cnf_path)
self.assertTrue(cnf)
self._assert_dicts_equal(cnf)

# vim:sw=4:ts=4:et:

0 comments on commit cd30fcd

Please sign in to comment.