From: Thomas V. S. <tho...@us...> - 2011-01-21 11:00:27
|
Update of /cvsroot/pychecker/pychecker/test In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20149/test Modified Files: test_internal.py Log Message: * pychecker/CodeChecks.py: Handle sibling imports, where a module could be importing another living in the same directory. When handling IMPORT_NAME, pass the current's module moduleDir as the sibling module dir so we can load the ones that are as such, and tag them properly in the PCModules. * pychecker/check.py: Track both PC Modules and normal python modules added/loaded after importing all files to be checked. Delete the modules that are likely to be a sibling module from sys.modules, because they pollute that namespace by pretending they are an importable module from sys.path when they were a side effect of loading the files we were interested in. * pychecker/checker.py: Find a good moduleDir for the candidate files. * test/test_internal.py: Allow PYCHECKER_DEBUG as an env var so runs of trial can be done with debugging. Fix variables assert. Test now passes. Index: test_internal.py =================================================================== RCS file: /cvsroot/pychecker/pychecker/test/test_internal.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- test_internal.py 18 Jan 2011 09:09:21 -0000 1.17 +++ test_internal.py 21 Jan 2011 11:00:18 -0000 1.18 @@ -29,6 +29,8 @@ def check(self, paths): config = Config.Config() config.ignoreStandardLibrary = 1 + if os.environ.get('PYCHECKER_DEBUG'): + config.debug = 1 from pychecker.check import _check warnings = _check(paths, cfg=config) @@ -160,14 +162,16 @@ # check the module from which we are starimporting; # it should have been loaded as a side effect pcmodule = pcmodules.getPCModule("starimportfrom", moduleDir="input") - # FIXME; pcmodule has wrong moduleDir - pcmodule = pcmodules.getPCModule("starimportfrom", moduleDir=None) + self.failUnless(pcmodule, pcmodules._getPCModulesDict()) self.assertEquals(pcmodule.moduleName, "starimportfrom") self.assertEquals(pcmodule.moduleDir, "input") variables = [v for v in pcmodule.variables.keys() if v not in Config._DEFAULT_VARIABLE_IGNORE_LIST] - self.assertEquals(variables, []) + if utils.pythonVersion() >= utils.PYTHON_2_6: + self.assertEquals(pcmodule.variables.keys(), ["__package__"]) + else: + self.assertEquals(pcmodule.variables.keys(), []) self.assertEquals(pcmodule.classes.keys(), []) self.assertEquals(pcmodule.functions.keys(), ["_", ]) self.assertEquals(pcmodule.modules.keys(), ["gettext", ]) @@ -206,7 +210,5 @@ # self.assertEquals(pcmodule.codes[0].stack, []) self.assertEquals(pcmodule.codes[1].stack, []) - test_star_import.todo = 'make functions keyed on alias' - if __name__ == '__main__': unittest.main() |