def create_arg_test(env=None): hutch = 'temp_create' test_dir = CFG_PATH.parent.parent.parent / hutch if test_dir.exists(): shutil.rmtree(test_dir) with cli_args(['hutch_python', '--create', hutch]): with restore_logging(): setup_cli_env() assert test_dir.exists() # Make sure conf.yml is valid load(str(test_dir / 'conf.yml')) # Make sure we picked the correct env if env is not None: with (test_dir / 'temp_createversion').open() as f: lines = f.readlines() has_env = False for line in lines: if 'CONDA_ENVNAME' in line: has_env = True assert env == line.split("'")[-2] break assert has_env shutil.rmtree(test_dir)
def test_start_user(): logger.debug('test_start_user') with cli_args(['hutch_python', '--cfg', CFG]): with restore_logging(): setup_cli_env() # OSError from opening ipython shell with pytest.raises(OSError): start_user() script = str(Path(__file__).parent / 'script.py') with cli_args(['hutch_python', '--cfg', CFG, script]): with restore_logging(): setup_cli_env() # No OSError because we're just running a print script # Setting the name that script.py needs should avoid a NameError because # this is supposed to run the script in the enclosing frame unique_device = 4 # NOQA start_user()
def test_sim_arg(): logger.debug('test_sim_arg') with cli_args(['hutch_python', '--cfg', CFG, '--sim']): with restore_logging(): setup_cli_env()
def test_setup_cli_no_args(): logger.debug('test_setup_cli_no_args') with cli_args(['hutch_python']): with restore_logging(): setup_cli_env()
def test_setup_cli_normal(): logger.debug('test_setup_cli') with cli_args(['hutch_python', '--cfg', CFG]): with restore_logging(): setup_cli_env()