[apycotlib] change option names to avoid "." (closes #3024946)
authorPaul Tonelli <paul.tonelli@logilab.fr>
Wed, 24 Jul 2013 14:10:35 +0200
changeset 1434 a9f785f79a3c
parent 1433 6c8893df6244
child 1435 e46aceaf338c
[apycotlib] change option names to avoid "." (closes #3024946) These option names are passed as parameters and parameters cannot contains dots. The names have been simplified when possible, or . replaced by _ in case of collision. Also update tests to take these changes into account
_apycotlib/checkers/python.py
recipes.py
test/unittest_checkers.py
--- a/_apycotlib/checkers/python.py	Tue Aug 06 09:57:26 2013 +0200
+++ b/_apycotlib/checkers/python.py	Wed Jul 24 14:10:35 2013 +0200
@@ -204,7 +204,7 @@
     parsed_content = 'stdout'
     options_def = PYVERSIONS_OPTIONS.copy()
     options_def.update({
-        'pytest.extra_argument': {
+        'pytest_extra_argument': {
             'type': 'string',
             'help': ('extra argument to give to pytest. Add this option multiple '
                      'times in the correct order to give several arguments.'),
@@ -244,7 +244,7 @@
             command = ['-c', 'from logilab.common.pytest import run; import sys; sys.argv=["pytest", "--coverage"]; run()']
         else:
             command = ['-c', 'from logilab.common.pytest import run; run()']
-        extraargs = self.options.get("pytest.extra_argument", [])
+        extraargs = self.options.get("pytest_extra_argument", [])
         if not isinstance(extraargs, list):
             command.append(extraargs)
         else:
@@ -573,14 +573,14 @@
     """
     id = 'pycoverage'
     options_def = {
-        'coverage.threshold': {
+        'coverage_threshold': {
             'type': 'int', 'default': 80,
             'help': ('integer between 1 and 100 telling expected percent coverage '
                      'to pass this check. Default to 80.\n'
                      'PARTIAL returned when cover rate between threshold and threshold / 2.\n'
                      'ERROR returned when cover rate under threshold / 2'),
         },
-        'coverage.data': {
+        'coverage_data': {
             'required': True,
             'help': 'collect coverage data file',
         },
@@ -593,8 +593,8 @@
 
     def do_check(self, test):
         """run the checker against <path> (usually a directory)"""
-        self.threshold = float(self.options.get('coverage.threshold')) / 100
-        self.coverage_data = self.options.get('coverage.data')
+        self.threshold = float(self.options.get('coverage_threshold')) / 100
+        self.coverage_data = self.options.get('coverage_data')
         if not exists(self.coverage_data):
             self.writer.fatal('no coverage information', path=self.coverage_data)
             return NODATA
--- a/recipes.py	Tue Aug 06 09:57:26 2013 +0200
+++ b/recipes.py	Wed Jul 24 14:10:35 2013 +0200
@@ -19,7 +19,7 @@
 with na.apycot_environment(plan) as test:
     na.install_environment(test)
     checker, status = test.run_checker('pyunit', pycoverage=True)
-    checker, status = test.run_checker('pycoverage')
+    checker, status = test.run_checker('pycoverage', coverage_data=checker.coverage_data)
     checker, status = test.run_checker('pylint')
 '''
 def create_full_recipe(session):
--- a/test/unittest_checkers.py	Tue Aug 06 09:57:26 2013 +0200
+++ b/test/unittest_checkers.py	Wed Jul 24 14:10:35 2013 +0200
@@ -240,13 +240,13 @@
         goodfile = osp.join(datadir, 'data/goodpkg2.4/tests/.coverage')
         os.environ['COVERAGE_FILE'] = goodfile # FIXME
 
-        pycoverage = PyCoverageChecker(WRITER, {'coverage.data': osp.join(datadir, 'data/unknown')})
+        pycoverage = PyCoverageChecker(WRITER, {'coverage_data': osp.join(datadir, 'data/unknown')})
         addTest(ModuleCheckerTest(pycoverage, ['goodpkg'], 'chks_test_nodata'))
-        pycoverage = PyCoverageChecker(WRITER, {'coverage.threshold': 80,
-                                                'coverage.data': goodfile})
+        pycoverage = PyCoverageChecker(WRITER, {'coverage_threshold': 80,
+                                                'coverage_data': goodfile})
         addTest(ModuleCheckerTest(pycoverage, ['goodpkg'], 'chks_test_failure'))
-        pycoverage = PyCoverageChecker(WRITER, {'coverage.threshold': 0,
-                                                'coverage.data': goodfile})
+        pycoverage = PyCoverageChecker(WRITER, {'coverage_threshold': 0,
+                                                'coverage_data': goodfile})
         addTest(ModuleCheckerTest(pycoverage, ['goodpkg'], 'chks_test_success'))
 
     ##### PyLintChecker #####