def from_pyproject_toml(pyproject_toml: Path = None) -> "AutohooksConfig": if pyproject_toml is None: pyproject_toml = get_pyproject_toml_path() if not pyproject_toml.exists(): return AutohooksConfig() config_dict = tomlkit.loads(pyproject_toml.read_text()) return AutohooksConfig(config_dict)
def test_with_env_pwd(self): os.environ['PWD'] = str(self.temp_path) setup_py = self.temp_path / 'setup.py' setup_py.touch() pyproject_toml_path = get_pyproject_toml_path() self.assertEqual(pyproject_toml_path, self.temp_path / 'pyproject.toml')
def load_config_from_pyproject_toml(pyproject_toml=None): if pyproject_toml is None: pyproject_toml = get_pyproject_toml_path() if not pyproject_toml.exists(): return AutohooksConfig() config_dict = toml.load(str(pyproject_toml)) return AutohooksConfig(config_dict)
def test_with_pyproject_toml_file(self): pyproject_toml_file = self.temp_path / 'pyproject.toml' pyproject_toml_file.touch() sub_path = self.temp_path / 'foo' sub_path.mkdir() pyproject_toml_path = get_pyproject_toml_path(sub_path) self.assertEqual(pyproject_toml_path, self.temp_path / 'pyproject.toml')