mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 19:46:54 +00:00
Add check for unicode replacement characters
This commit is contained in:
parent
a18c5af5d4
commit
9e417077fc
5 changed files with 55 additions and 0 deletions
13
tests/check_unicode_replacement_char_test.py
Normal file
13
tests/check_unicode_replacement_char_test.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from pre_commit_hooks import check_unicode_replacement_char
|
||||
|
||||
|
||||
def test_failure(tmpdir):
|
||||
f = tmpdir.join('f.txt')
|
||||
f.write_text(str(b'\x80abc', errors='replace'), encoding='utf-8')
|
||||
assert check_unicode_replacement_char.main((f.strpath,)) == 1
|
||||
|
||||
|
||||
def test_success(tmpdir):
|
||||
f = tmpdir.join('f.txt')
|
||||
f.write_text(str(b'\x80abc', errors='backslashreplace'), encoding='utf-8')
|
||||
assert check_unicode_replacement_char.main((f.strpath,)) == 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue