def report(self, results):
        """

        :param results: (success[], error[], missing_filters_for_rule_ids[])
        :type results: tuple
        """
        # TODO: implement result report
        info("Results: {results}".format(results=repr(results)))
Example #2
0
def test_verify_import_bad_package_test():
    """This test verifies the negative case used in the test_importing_found_exportables() test"""
    import_str = "from refactor_imports.bad_package import DoesNotExist"
    try:
        tree = ast.parse(import_str, "eval")
        compile(tree, "<string>", "exec")
        info(import_str)
        assert False, import_str
    except Exception as ex:
        assert True, import_str + " : " + str(ex)
Example #3
0
def test_importing_found_exportables():
    """
    This test gets all of the exportable objects then tries to parse and compile each import statement.
    """
    analyzer = CodeAnalyzer(top_dir)
    exportables = analyzer.exportables()

    for exportable in exportables:
        try:
            tree = ast.parse(exportable.import_str, "eval")
            compile(tree, "<string>", "exec")
            info(exportable.import_str)
            assert True, exportable.import_str
        except Exception as ex:
            assert False, exportable.import_str + " : " + str(ex)
Example #4
0
    def module_trace(module_spec, file_spec, tracer, q):
        """
        Load self.file_path and trace the imports

        :param module_spec: module path
        :type module_spec: str
        :param tracer: tracer context
        :type tracer: ImportTracer.ModuleTracer
        """

        # trace the import of the module
        info("__import__({name})".format(name=module_spec))
        sys.settrace(tracer.trace_imports)
        try:
            __import__(module_spec)
        except ImportError as ex:
            error("Error tracing import.  " + str(ex))
        sys.settrace(None)
        q.put(tracer.to_patch(file_spec))