Exemplo n.º 1
0
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():
            main()

    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_createenv').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)
Exemplo n.º 2
0
def test_run_script():
    logger.debug('test_run_script')

    # Will throw a name error unless we run the script inside the full env
    with cli_args([
            'hutch_python', '--cfg', CFG, '--debug',
            str(Path(__file__).parent / 'script.py')
    ]):
        with restore_logging():
            main()
Exemplo n.º 3
0
def test_create_arg():
    logger.debug('test_create_arg_dev')
    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():
            main()

    assert test_dir.exists()

    # Make sure conf.yml is valid
    load(str(test_dir / 'conf.yml'))
    shutil.rmtree(test_dir)
Exemplo n.º 4
0
def test_sim_arg(no_ipython_launch):
    logger.debug('test_sim_arg')

    with cli_args(['hutch_python', '--cfg', CFG, '--sim']):
        with restore_logging():
            main()
Exemplo n.º 5
0
def test_main_no_args(no_ipython_launch):
    logger.debug('test_main_no_args')

    with cli_args(['hutch_python']):
        with restore_logging():
            main()
Exemplo n.º 6
0
def test_main_normal(no_ipython_launch):
    logger.debug('test_main_normal')

    with cli_args(['hutch_python', '--cfg', CFG]):
        with restore_logging():
            main()