Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
options.fork)
test_suite.addTest(
filetests.handle_directory(
os.path.join(sys.prefix, 'lib', 'python'+sys.version[:3], 'test'),
'pyregr'))
result = unittest.TextTestRunner(verbosity=options.verbosity).run(test_suite)
if options.coverage:
coverage.stop()
ignored_modules = ('Options', 'Version', 'DebugFlags', 'CmdLine')
modules = [ module for name, module in sys.modules.items()
if module is not None and
name.startswith('Cython.Compiler.') and
name[len('Cython.Compiler.'):] not in ignored_modules ]
coverage.report(modules, show_missing=0)
if missing_dep_excluder.tests_missing_deps:
sys.stderr.write("Following tests excluded because of missing dependencies on your system:\n")
for test in missing_dep_excluder.tests_missing_deps:
sys.stderr.write(" %s\n" % test)
if options.with_refnanny:
import refnanny
sys.stderr.write("\n".join([repr(x) for x in refnanny.reflog]))
sys.exit(not result.wasSuccessful())
coverage.use_cache(0)
coverage.start()
result = super(CoverageRunner, self).run_tests(*args, **kwargs)
if run_with_coverage:
coverage.stop()
print('')
print('----------------------------------------------------------------------')
print(' Unit Test Code Coverage Results')
print('----------------------------------------------------------------------')
coverage_modules = []
for module in settings.COVERAGE_MODULES:
coverage_modules.append(__import__(module, globals(),
locals(), ['']))
coverage.report(coverage_modules, show_missing=1)
print('----------------------------------------------------------------------')
return result
coverage.stop()
true_out.write("\nPreparing coverage report...\n")
from sqlalchemy import sql, orm, engine, \
ext, databases, log
import sqlalchemy
for modset in [
_iter_covered_files(sqlalchemy, recursive=False),
_iter_covered_files(databases),
_iter_covered_files(engine),
_iter_covered_files(ext),
_iter_covered_files(orm),
]:
coverage.report(list(modset),
show_missing=False, ignore_errors=False,
file=true_out)
atexit.register(_stop)
print "***** Unittest *****"
test_args = {'verbosity': 1}
suite = unittest.TestLoader().loadTestsFromNames(TEST_NAMES)
unittest.TextTestRunner(**test_args).run(suite)
if 'doctest' in TESTS:
t0 = time.time()
print "\n***** Doctest *****"
for mod in modules:
doctest.testmod(mod, verbose=VERBOSE)
td = time.time() - t0
print " Tests took %.3f seconds" % (td, )
print "\n***** Coverage Python *****"
coverage.stop()
coverage.report(modules, ignore_errors=1, show_missing=1)
coverage.erase()
def _stop():
coverage.stop()
true_out.write("\nPreparing coverage report...\n")
coverage.report(list(_iter_covered_files()),
show_missing=False, ignore_errors=False,
file=true_out)
atexit.register(_stop)
elif not is_in_packages(name, packages):
continue
elif is_in_packages(name, ['django']):
continue
filename = mod.__file__.replace('.pyc', '.py')
if test_re.match(filename):
continue
st = os.stat(filename)
if st.st_size > 1:
files.add(filename)
if files:
coverage.report(list(files))
coverage.erase()
def end_coverage():
coverage.the_coverage.start()
coverage.the_coverage.collect()
coverage.the_coverage.stop()
modules = [p[:-3] for p in os.listdir('../polysh') if p.endswith('.py')]
coverage.report(['../polysh/%s.py' % (m) for m in modules])
remove_coverage_files()
# Prevent the atexit.register(the_coverage.save) from recreating the files
coverage.the_coverage.usecache = coverage.the_coverage.cache = None
coverage.stop()
coverage_modules = []
if test_labels:
for label in test_labels:
# Don't report coverage if you're only running a single
# test case.
if '.' not in label:
app = get_app(label)
coverage_modules.extend(get_all_coverage_modules(app))
else:
for app in get_apps():
coverage_modules.extend(get_all_coverage_modules(app))
if coverage_modules:
coverage.report(coverage_modules, show_missing=1)
return results
elif self.unittest:
# Running a unit test is done by opening the unit test file
# as a module and running the tests within that module.
print("Running test cases in unittest file: %s..." % self.unittest)
import imp, unittest
fp = open(self.unittest)
test_module = imp.load_source("gaphor_test", self.unittest, fp)
test_suite = unittest.TestLoader().loadTestsFromModule(test_module)
# test_suite = unittest.TestLoader().loadTestsFromName(self.unittest)
test_runner = unittest.TextTestRunner(verbosity=self.verbosity)
result = test_runner.run(test_suite)
if self.coverage:
print()
print("Coverage report:")
coverage.report(self.unittest)
sys.exit(not result.wasSuccessful())
elif self.file:
print("Executing file: %s..." % self.file)
dir, f = os.path.split(self.file)
print("Extending PYTHONPATH with %s" % dir)
# sys.path.append(dir)
execfile(self.file, {})
else:
print("Launching Gaphor...")
del sys.argv[1:]
starter = load_entry_point(
"gaphor==%s" % (self.distribution.get_version(),),
"console_scripts",
"gaphor",
)