Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _run(self):
argv = ['']
argv += self.test_args.split()
collector = Nose2ResultsCollector()
with open(os.devnull, 'w') as devnull:
with redirect_stdout(devnull):
with redirect_stderr(devnull):
nose2.discover(argv=argv, extraHooks=[('testOutcome', collector)], exit=False)
failures = [x for x in collector.events if x.outcome != 'passed']
return (not failures, [(str(r.test), traceback.format_exception(*r.exc_info)) for r in failures])
* http://nose.readthedocs.org/en/latest/usage.html#basic-usage
"""
import os
import sys
import nose2
import django
from django.conf import settings
if __name__ == '__main__':
settings.configure()
django.setup()
settings.BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
settings.DJANGO_LIVESYNC = {'PORT': 9001, 'HOST': '127.0.0.1'}
result = nose2.discover()
if not result:
sys.exit(1)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
import nose2
except ImportError:
message = """nose2 package not installed, install test requirements with:
pip install -r requirements-test.txt
"""
raise ImportError(message)
if __name__ == "__main__":
result = nose2.discover()
if result is False:
import sys
sys.exit(1)
test_env = os.environ.copy()
test_env.update({"SERVER_LOG_LEVEL": args.log_level})
home = p.join(os.environ["TOX_ENV_DIR"], "tmp", "home")
os.makedirs(home)
if not _ON_WINDOWS:
test_env.update({"HOME": home})
else:
test_env.update({"LOCALAPPDATA": home})
_logger.info("nose2 args: %s", nose_args)
with mock.patch.dict("os.environ", test_env):
successful = nose2.discover(exit=False, argv=nose_args).result.wasSuccessful()
return successful
def runNose2():
import nose2
nose2.discover(exit=False)