def run_tests_with_lettuce(self): curr_dir = os.getcwd() try: lettuce_dir = os.path.join(curr_dir, 'tests') os.chdir(lettuce_dir) lettuce_cli.main('--verbosity=0 --with-xunit') finally: os.chdir(curr_dir)
if want_install: # backup python path & args before changing it sys_path = sys.path sys_argv = sys.argv sys.path.insert(0, os.path.abspath(os.path.pardir)) # now the path is altered, import pyg import pyg # try to run lettuce's installation or upgrade try: sys.argv = ['pyg', 'install', '-A', 'lettuce'] r = pyg.main() except (Exception, SystemExit) as e: print("Install failed ! Code:", e) else: if r: print("Install failed ! Code:", r) # restore standard variables sys.path = sys_path sys.argv = sys_argv from lettuce.lettuce_cli import main # go to that file's folder and set KEEPENV if not set os.chdir(os.path.dirname(os.path.abspath(__file__))) if 'KEEPENV' not in os.environ: from tempfile import mkdtemp os.environ['KEEPENV'] = mkdtemp('_test_env', 'pyg_') # start lettuce ! sys.exit(main())