示例#1
0
def test_pearl_env_home(home, expected_home, tmp_path):
    with mock.patch(_MODULE_UNDER_TEST + '.os') as os_mock:
        home_dir = tmp_path / 'home-dir'
        (home_dir / '.local/share/pearl').mkdir(parents=True)
        default_environ = {'HOME': home_dir}

        os_mock.environ = dict(default_environ)

        if home is not None:
            home = tmp_path / home
            home.mkdir(parents=True, exist_ok=True)
        assert str(PearlEnvironment._get_home(home=home)) == str(tmp_path /
                                                                 expected_home)
示例#2
0
def test_pearl_env_home_not_directory(tmp_path):
    (tmp_path / 'file').touch()
    with pytest.raises(ValueError):
        PearlEnvironment._get_home(tmp_path / 'file')
示例#3
0
def test_pearl_env_home_not_exist():
    with mock.patch(_MODULE_UNDER_TEST + '.os') as os_mock:
        os_mock.environ = {'HOME': '/home/myhome'}
        PearlEnvironment._get_home(env_initialized=False)
        with pytest.raises(ValueError):
            PearlEnvironment._get_home()