1# coding: utf-8 2from __future__ import unicode_literals, division, absolute_import, print_function 3 4import os 5import site 6import sys 7 8from . import build_root, requires_oscrypto 9from ._import import _preload 10 11 12deps_dir = os.path.join(build_root, 'modularcrypto-deps') 13if os.path.exists(deps_dir): 14 site.addsitedir(deps_dir) 15 16if sys.version_info[0:2] not in [(2, 6), (3, 2)]: 17 from .lint import run as run_lint 18else: 19 run_lint = None 20 21if sys.version_info[0:2] != (3, 2): 22 from .coverage import run as run_coverage 23 run_tests = None 24 25else: 26 from .tests import run as run_tests 27 run_coverage = None 28 29 30def run(): 31 """ 32 Runs the linter and tests 33 34 :return: 35 A bool - if the linter and tests ran successfully 36 """ 37 38 _preload(requires_oscrypto, True) 39 40 if run_lint: 41 print('') 42 lint_result = run_lint() 43 else: 44 lint_result = True 45 46 if run_coverage: 47 print('\nRunning tests (via coverage.py)') 48 sys.stdout.flush() 49 tests_result = run_coverage(ci=True) 50 else: 51 print('\nRunning tests') 52 sys.stdout.flush() 53 tests_result = run_tests(ci=True) 54 sys.stdout.flush() 55 56 return lint_result and tests_result 57