def ml_proj():
    """Uses the create_ml_project() method from the auto_pb module and returns a
    ProjectBuilder instance."""
    set_keyboard_input(['machine-learning-project', 'RaDroid'])
    ml_proj = create_ml_project()
    yield ml_proj
    rmtree(ml_proj.proj_dir)
def sim_proj():
    """Uses the create_simple_project() method from the auto_pb module and
    returns a ProjectBuilder instance."""
    set_keyboard_input(['simple-project', 'RaDroid'])
    sim_proj = create_simple_project()
    yield sim_proj
    rmtree(sim_proj.proj_dir)
def ml_proj_conda_env():
    set_keyboard_input(['machine-learning-project-2', 'RaDroid'])
    ml_proj = create_ml_project(create_conda_env=True)

    try:
        # Get conda environments
        envs = subprocess.check_output(['conda', 'env', 'list'])
        envs_list = [env.strip() for env in str(envs).split('\\n')]

        proj_env = ml_proj.proj_dir / 'env'
        assert str(proj_env) in envs_list
    finally:
        if ml_proj.proj_dir.exists():
            rmtree(ml_proj.proj_dir)
def test_instantiating_right_2():
    set_keyboard_input(['test_2', 'Raj Dholakia'])
    path = Path.cwd() / 'tests'
    pb = ProjectBuilder(path=str(path))
    assert pb.path == path
def test_instantiating_error_2():
    set_keyboard_input(['endswith-',  # Ends with '-'
                        'One space',  # Contains white space.
                        '_incorrect'])  # Start with '_'
    with pytest.raises(UserWarning):
        ProjectBuilder()
def test_instantiating_error_1():
    set_keyboard_input(['-test_1',  # Start with '-'
                        '$Te*st=2',  # Contains illegal special charaters.
                        'next&warning'])  # Contains one illegal character.
    with pytest.raises(UserWarning):
        ProjectBuilder()
def pb():
    set_keyboard_input(['test', 'RaDroid'])
    pb = ProjectBuilder()
    yield pb
    if pb.proj_dir is not None and pb.proj_dir.exists():
        rmtree(pb.proj_dir)