diff --git a/src/prisma/_config.py b/src/prisma/_config.py index d3ca51458..92ccaa109 100644 --- a/src/prisma/_config.py +++ b/src/prisma/_config.py @@ -108,7 +108,7 @@ def load(cls, path: Path | None = None) -> Config: path = Path('pyproject.toml') if path.exists(): - config = tomlkit.loads(path.read_text()).get('tool', {}).get('prisma', {}) + config = tomlkit.loads(path.read_text(encoding='utf-8')).get('tool', {}).get('prisma', {}) else: config = {} diff --git a/tests/test_config.py b/tests/test_config.py index c5fe9386f..4a9ea3251 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -41,6 +41,24 @@ def test_no_file(testdir: Testdir) -> None: assert isinstance(config.prisma_version, str) +def test_with_file(testdir: Testdir) -> None: + """Can works config from pyproject.toml successfully""" + path = Path('pyproject.toml') + testdir.makefile( + '.toml', + pyproject=dedent( + """ + [tool.prisma] + prisma_version = '0.1.2.3' + """ + ), + ) + + assert path.exists() + config = Config.load(path) + assert config.prisma_version == '0.1.2.3' + + def test_loading(testdir: Testdir) -> None: """Config loading overrides defaults""" testdir.makefile(