def setUp(self): self._old_output = get_output() self._old_level = log.level self.captured = StringIO() set_output(self.captured) log.level = self.log_level super(CapturedLogger, self).setUp()
def tearDown(self): set_output(self._old_output) log.level = self._old_level super(CapturedLogger, self).tearDown()
import os from path import path import logging from kinbaku.report import console, report from kinbaku.plugin import KinbakuPlugin, publish_to_commandline class PythoscopeVox: """ a place for pythoscope to talk out into """ @staticmethod def pythoscope_vox(*args, **kargs): report(' ',*args, **kargs) write = pythoscope_vox from pythoscope import logger from pythoscope import init_project logger.set_output(PythoscopeVox) class Pythoscope(KinbakuPlugin): """ """ @classmethod def spawn(kls, **kargs): return Pythoscope() @publish_to_commandline def generate(self, input_dir): """ generates empty unittests from project-root at @input_dir """ from kinbaku.codebase import plugin as CodeBase with CodeBase(input_dir, gloves_off=True, workspace=None) as codebase: # mirror fpath into codebase and get it's name #codebase.mirror()
pythoscope_path = os.path.join(os.path.dirname(__file__), os.pardir) sys.path.insert(0, os.path.abspath(pythoscope_path)) # Make sys.stdout the logger's output stream, so nose capture # plugin can get hold of it. # We can't set_output to sys.stdout directly, because capture # plugin changes that before each test. class AlwaysCurrentStdout: def __getattr__(self, name): return getattr(sys.stdout, name) from pythoscope.logger import DEBUG, log, set_output set_output(AlwaysCurrentStdout()) log.level = DEBUG # Make sure all those suspiciously looking classes and functions aren't treated # as tests by nose. from pythoscope.store import TestClass, TestMethod from pythoscope.generator import add_tests_to_project, TestGenerator from pythoscope.generator.adder import add_test_case, add_test_case_to_project, \ find_test_module, module_path_to_test_path, replace_test_case from pythoscope.generator import generate_test_case from pythoscope.generator.builder import generate_test_contents from pythoscope.generator.assertions import test_timeline_for_call from pythoscope.generator.selector import testable_calls TestClass.__test__ = False TestMethod.__test__ = False
""" # Make pythoscope importable directly from the test modules. import os, sys pythoscope_path = os.path.join(os.path.dirname(__file__), os.pardir) sys.path.insert(0, os.path.abspath(pythoscope_path)) # Make sys.stdout the logger's output stream, so nose capture # plugin can get hold of it. # We can't set_output to sys.stdout directly, because capture # plugin changes that before each test. class AlwaysCurrentStdout: def __getattr__(self, name): return getattr(sys.stdout, name) from pythoscope.logger import DEBUG, log, set_output set_output(AlwaysCurrentStdout()) log.level = DEBUG # Make sure all those suspiciously looking classes and functions aren't treated # as tests by nose. from pythoscope.store import TestClass, TestMethod from pythoscope.generator import add_tests_to_project, TestGenerator from pythoscope.generator.adder import add_test_case, add_test_case_to_project, \ find_test_module, module_path_to_test_path, replace_test_case from pythoscope.generator import generate_test_case from pythoscope.generator.builder import generate_test_contents from pythoscope.generator.assertions import test_timeline_for_call from pythoscope.generator.selector import testable_calls TestClass.__test__ = False TestMethod.__test__ = False