[narval] ATest has no project_path() any more draft
authorDavid Douard <david.douard@logilab.fr>
Thu, 13 Nov 2014 14:50:54 +0100
changeset 1750 6c752f8e5fc5
parent 1749 7cdbb66fb2c4
child 1751 56eb553a3618
[narval] ATest has no project_path() any more
_narval/checkers/apycot/python.py
--- a/_narval/checkers/apycot/python.py	Thu Nov 13 14:49:22 2014 +0100
+++ b/_narval/checkers/apycot/python.py	Thu Nov 13 14:50:54 2014 +0100
@@ -13,7 +13,7 @@
 import sys
 import re
 from commands import getoutput
-from os.path import join, exists
+from os.path import join, exists, basename
 from test import test_support
 from warnings import warn
 from lxml import etree
@@ -52,9 +52,9 @@
     if 'install_path' in config:
         return config['install_path']
     modname = config.get('python_modname')
-    if not modname and exists(join(test.tmpdir, test.project_path(), '__pkginfo__.py')):
+    if not modname and exists(join(self.cwd, '__pkginfo__.py')):
         from logilab.devtools.lib.pkginfo import PackageInfo
-        pkginfo = PackageInfo(directory=test.project_path())
+        pkginfo = PackageInfo(directory=self.cwd)
         modname = pkginfo.modname
         distname = pkginfo.distname or modname
         package = pkginfo.subpackage_of
@@ -67,7 +67,7 @@
             return join(cubespdir, 'cubes', modname)
     if modname:
         try:
-            path = join(INSTALL_PREFIX[test.project_path()], *modname.split('.'))
+            path = join(INSTALL_PREFIX[self.cwd], *modname.split('.'))
         except KeyError:
             pass
         else:
@@ -75,7 +75,7 @@
             if cfg.get('subpath'):
                 path = join(path, cfg['subpath'])
             return path
-    return test.project_path(subpath=True)
+    return self.cwd
 
 
 class PythonSyntaxChecker(AbstractFilteredFileChecker):
@@ -234,10 +234,7 @@
         """run the checker against <path> (usually a directory)"""
         test_support.verbose = 0
         self.test = test
-        self.cwd = test.project_path(subpath=True)
-        if not pyversions(self.test):
-            self.writer.error('no required python version available')
-            return ERROR
+        self.cwd = self.options['path']
         return SUCCESS
 
     def do_check(self, test):
@@ -280,6 +277,9 @@
         if isinstance(command, basestring):
             command = [command]
         command = self.get_command(command, python)
+        self.writer.info(' '.join(command), path=basename(command[-1]))
+        self.writer.debug(os.environ['PYTHONPATH'], path='PYTHONPATH')
+        self.writer.debug(self.cwd, path='CWD')
         cmd = ParsedCommand(self.writer, command,
                             parsercls=self.parsercls,
                             parsed_content=self.parsed_content,
@@ -351,7 +351,7 @@
     def do_check(self, test):
         status = SUCCESS
         testdirs = self.options.get("test_dirs")
-        basepath = test.project_path(subpath=True)
+        basepath = self.cwd
         for testdir in testdirs:
             testdir = join(basepath, testdir)
             if exists(testdir):
@@ -493,7 +493,7 @@
         # register checkers
         pycheckers.initialize(linter)
         # load configuration
-        package_wd_path = test.project_path()
+        package_wd_path = self.cwd
         if exists(join(package_wd_path, 'pylintrc')):
             linter.load_file_configuration(join(package_wd_path, 'pylintrc'))
         else:
@@ -521,7 +521,7 @@
             raise
         except Exception:
             self.writer.error('Error while processing pylint evaluation',
-                              path=test.project_path(subpath=True), tb=True)
+                              path=self.cwd, tb=True)
             note = 0
         self.writer.raw('statements', '%i' % linter.stats['statement'], 'result')
         if note < threshold:
@@ -634,7 +634,7 @@
         covertool.use_cache(self.options.get('coverage_data'))
         covertool.load()
         try:
-            report_file = join(test.project_path(), "coverage.xml")
+            report_file = join(self.cwd, "coverage.xml")
             covertool.xml_report(outfile=report_file, ignore_errors=True)
             report = etree.parse(report_file).getroot()
             pc_cover = float(report.attrib.get('line-rate'))