def test_autotest_plugin(self): monitor = Monitor(__file__) descriptor = ModuleDescriptor(read_module_code(__file__)) event = Event(Event.MODULE_MODIFIED, descriptor) plugin = FakeAutotest(event, monitor, {}); self.assertEqual(descriptor, plugin.descriptor) self.assertTrue(callable(plugin)) plugin() self.assertEqual([descriptor], plugin.testables) self.assertEqual(['--loglevel', LOGGER.getEffectiveLevel()], plugin.extra_arguments)
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)