Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import sys
import unittest
setup_file = sys.modules["__main__"].__file__
setup_dir = os.path.abspath(os.path.dirname(setup_file))
tests = unittest.TestLoader().discover(
os.path.join(setup_dir, "tests"), pattern="*.py"
)
try:
# https://github.com/CleanCut/green/issues/50
from green.runner import run
from green.suite import GreenTestSuite
from green.config import default_args
default_args.verbose = 3
run(GreenTestSuite(tests), sys.stdout, default_args)
except ImportError:
unittest.TextTestRunner(verbosity=2).run(tests)
def __init__(self, tests=(), args=None):
# You should either set GreenTestSuite.args before instantiation, or
# pass args into __init__
self._removed_tests = 0
self.allow_stdout = default_args.allow_stdout
self.full_test_pattern = 'test' + default_args.test_pattern
self.customize(args)
super(GreenTestSuite, self).__init__(tests)
def run_tests(self):
import sys
import unittest
setup_file = sys.modules["__main__"].__file__
setup_dir = os.path.abspath(os.path.dirname(setup_file))
tests = unittest.TestLoader().discover(
os.path.join(setup_dir, "tests"), pattern="*.py"
)
try:
# https://github.com/CleanCut/green/issues/50
from green.runner import run
from green.suite import GreenTestSuite
from green.config import default_args
default_args.verbose = 3
run(GreenTestSuite(tests), sys.stdout, default_args)
except ImportError:
unittest.TextTestRunner(verbosity=2).run(tests)
def __init__(self, tests=(), args=None):
# You should either set GreenTestSuite.args before instantiation, or
# pass args into __init__
self._removed_tests = 0
self.allow_stdout = default_args.allow_stdout
self.full_test_pattern = 'test' + default_args.test_pattern
self.customize(args)
super(GreenTestSuite, self).__init__(tests)