-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(logging): ensure log files get opened in UTF-8 encoding
whilst almost all Python APIs assume UTF-8, this one appears to have retained backwards compatibility and might end up creating the file in a locale encoding instead fix(testing): fix unit tests on Windows, where an interactive console was being attempted to be creating due to an interaction between prompt_toolkit and pytest automatic stdout/in/err capture fix(testing): fix approval test files being written with non-utf8 locale on windows fix(testing): test 3.10 x {linux, windows} to get more relevant coverage given the limited build-minutes situation currently security: update packages to address pip-audit discovered vulnerability
- Loading branch information
Showing
12 changed files
with
90 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from typing import Any | ||
|
||
import approvaltests | ||
from approvaltests.scrubbers.scrubbers import Scrubber, combine_scrubbers | ||
|
||
__all__ = [ | ||
"TokenScrubber", | ||
"Scrubber", | ||
"combine_scrubbers", | ||
"verify", | ||
] | ||
|
||
|
||
class TokenScrubber(Scrubber): | ||
def __init__(self, tokens: dict[str, str]): | ||
self._tokens = tokens | ||
|
||
def __call__(self, data: str) -> str: | ||
result = data | ||
for token, search in self._tokens.items(): | ||
result = result.replace(search, "{" + token + "}") | ||
return result | ||
|
||
|
||
def verify( | ||
data: Any, # noqa: ANN401 | ||
*, | ||
options: approvaltests.Options | None = None, | ||
scrubber: Scrubber | None = None, | ||
**kwargs: Any | ||
) -> None: | ||
options = options or approvaltests.Options() | ||
if scrubber is not None: | ||
options = options.add_scrubber(scrubber) | ||
kwargs.setdefault("encoding", "utf-8") | ||
approvaltests.verify( | ||
data=data, | ||
options=options, | ||
**kwargs, | ||
) |