Skip to content

Commit

Permalink
feat: force utf-8 text snapshot encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Nov 2, 2022
1 parent aa9a405 commit 990c031
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pytest_insta/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class FmtText(Fmt[str]):
extension = ".txt"

def load(self, path: Path) -> str:
return path.read_text()
return path.read_text("utf-8")

def dump(self, path: Path, value: str):
path.write_text(value)
path.write_text(value, "utf-8")


class FmtBinary(Fmt[bytes]):
Expand All @@ -69,20 +69,20 @@ class FmtHexdump(Fmt[bytes]):
extension = ".hexdump"

def load(self, path: Path) -> bytes:
return hexload(path.read_text())
return hexload(path.read_text("utf-8"))

def dump(self, path: Path, value: bytes):
path.write_text("\n".join(hexdump(value)) + "\n")
path.write_text("\n".join(hexdump(value)) + "\n", "utf-8")


class FmtJson(Fmt[Any]):
extension = ".json"

def load(self, path: Path) -> Any:
return json.loads(path.read_text())
return json.loads(path.read_text("utf-8"))

def dump(self, path: Path, value: Any):
path.write_text(json.dumps(value, indent=2) + "\n")
path.write_text(json.dumps(value, indent=2) + "\n", "utf-8")


class FmtPickle(Fmt[Any]):
Expand Down

0 comments on commit 990c031

Please sign in to comment.