summaryrefslogtreecommitdiff
path: root/tko/parsers
diff options
context:
space:
mode:
authorjadmanski <jadmanski@592f7852-d20e-0410-864c-8624ca9c26a4>2009-04-01 18:18:32 +0000
committerjadmanski <jadmanski@592f7852-d20e-0410-864c-8624ca9c26a4>2009-04-01 18:18:32 +0000
commit9e6046acefe9e526aa0565f7dbc7b638b0c9f93b (patch)
tree031356315847af03bf5cedfc7fd2eec038618b31 /tko/parsers
parentc4c5c98d17c1ccb4716543e8c8aac0be8ef97edb (diff)
Convert the parser unit tests over to use the more portable dumbdbm as
the backing store. Unfortunately requires converting over all the existing results stores to use the dumbdbm format. Risk: Low Visibility: Improves parser unit test portability. Signed-off-by: John Admanski <jadmanski@google.com> git-svn-id: svn://test.kernel.org/autotest/trunk@2949 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'tko/parsers')
-rw-r--r--tko/parsers/test/execute_parser.py1
-rw-r--r--tko/parsers/test/scenario_base.py11
2 files changed, 9 insertions, 3 deletions
diff --git a/tko/parsers/test/execute_parser.py b/tko/parsers/test/execute_parser.py
index fb703f08..b597f500 100644
--- a/tko/parsers/test/execute_parser.py
+++ b/tko/parsers/test/execute_parser.py
@@ -25,7 +25,6 @@ def main():
parser.print_help()
sys.exit(1)
- sto = scenario_base.load_parser_result_store(scenario_dirpath, True)
results_dirpath = scenario_base.load_results_dir(scenario_dirpath)
harness = scenario_base.new_parser_harness(results_dirpath)
try:
diff --git a/tko/parsers/test/scenario_base.py b/tko/parsers/test/scenario_base.py
index 5947f933..01f27d4b 100644
--- a/tko/parsers/test/scenario_base.py
+++ b/tko/parsers/test/scenario_base.py
@@ -231,6 +231,13 @@ class BaseScenarioTestCase(unittest_hotfix.TestCase):
self.harness.status_version, self.expected_status_version)
+def shelve_open(filename, flag='c', protocol=None, writeback=False):
+ """A more system-portable wrapper around shelve.open, with the exact
+ same arguments and interpretation."""
+ import dumbdbm
+ return shelve.Shelf(dumbdbm.open(filename, flag), protocol, writeback)
+
+
def new_parser_harness(results_dirpath):
"""Ensure sane environment and create new parser with wrapper.
@@ -269,7 +276,7 @@ def store_parser_result(package_dirpath, parser_result, tag):
"""
copy = copy_parser_result(parser_result)
sto_filepath = path.join(package_dirpath, PARSER_RESULT_STORE)
- sto = shelve.open(sto_filepath)
+ sto = shelve_open(sto_filepath)
sto[tag] = copy
sto.close()
@@ -286,7 +293,7 @@ def load_parser_result_store(package_dirpath, open_for_write=False):
"""
open_flag = open_for_write and 'c' or 'r'
sto_filepath = path.join(package_dirpath, PARSER_RESULT_STORE)
- return shelve.open(sto_filepath, flag=open_flag)
+ return shelve_open(sto_filepath, flag=open_flag)
def store_results_dir(package_dirpath, results_dirpath):