Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): read using utf-8 #1002

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/prisma/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down
18 changes: 18 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down