コード例 #1
0
ファイル: test_analysis.py プロジェクト: wescleymatos/modipyd
 def test_module_in_package(self):
     mod = self.descriptors["tests_module"]
     self.assert_(has_subclass(mod, unittest.TestCase))
     mod = self.descriptors["tests_module.a"]
     self.assert_(has_subclass(mod, unittest.TestCase))
     mod = self.descriptors["tests_module.a2"]
     self.assert_(has_subclass(mod, unittest.TestCase))
コード例 #2
0
ファイル: test_analysis.py プロジェクト: wescleymatos/modipyd
    def test_package_relative_imports(self):
        if not HAS_RELATIVE_IMPORTS:
            return

        mod = self.descriptors["RA.RB.b"]
        self.assert_(has_subclass(mod, unittest.TestCase))

        mod = self.descriptors["RA.RB.b2"]
        self.assert_(has_subclass(mod, unittest.TestCase))

        mod = self.descriptors["RA.RB.b3"]
        self.assert_(has_subclass(mod, unittest.TestCase))

        mod = self.descriptors["RA.RB"]
        self.assert_(has_subclass(mod, unittest.TestCase))
コード例 #3
0
ファイル: test_analysis.py プロジェクト: ishikawa/modipyd
    def test_import_alias(self):
        path = join(FILES_DIR, 'import_alias')
        codes = list(collect_module_code(path, path))
        descriptors = build_module_descriptors(codes)

        foo = descriptors['foo']
        bar = descriptors['bar']

        # import foo module
        syspath = sys.path[:]
        try:
            sys.path.insert(0, path)
            import foo as f

            self.assert_(
                has_subclass(bar, f.Foo),
                "The module 'bar' should contain a subclass of 'foo.Foo'")
        finally:
            sys.path = syspath
コード例 #4
0
ファイル: plugins.py プロジェクト: ishikawa/modipyd
    def __call__(self):

        # Walking dependency graph in imported module to
        # module imports order.
        testables = []
        for desc in self.descriptor.walk_dependency_graph(reverse=True):
            LOGGER.info("-> Affected: %s" % desc.name)
            if has_subclass(desc, unittest.TestCase):
                LOGGER.debug("-> unittest.TestCase detected: %s" % desc.name)
                testables.append(desc)

        # Runntine tests
        if testables:
            # We can reload affected modules manually and run
            # all TestCase in same process. Running another process,
            # however, is simple and perfect solution.
            if LOGGER.isEnabledFor(logging.INFO):
                desc = ', '.join([x.name for x in testables])
                LOGGER.info("Running UnitTests: %s" % desc)
            # Propagates the level of modipyd.LOGGER to
            # the unittest runner subprocess.
            extra = ['--loglevel', LOGGER.getEffectiveLevel()]
            self.spawn_unittest_runner(testables, extra)
コード例 #5
0
ファイル: test_analysis.py プロジェクト: wescleymatos/modipyd
 def test_module_not_in_package(self):
     test_script = self.descriptors["test_script"]
     self.assert_(has_subclass(test_script, unittest.TestCase))
コード例 #6
0
ファイル: test_analysis.py プロジェクト: wescleymatos/modipyd
 def test_mixed_modules(self):
     mod = self.descriptors["tests_module.mixed"]
     self.assert_(has_subclass(mod, unittest.TestCase))