mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 19:46:54 +00:00
17 lines
456 B
Python
17 lines
456 B
Python
import pytest
|
|
|
|
from pre_commit_hooks.check_encoding import main
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
('content', 'encoding', 'expected'),
|
|
(
|
|
(b'Hello!', 'ascii', 0),
|
|
(b'Hello!', 'unknown-encoding', 2),
|
|
('Hello ☃!'.encode(), 'ascii', 1),
|
|
),
|
|
)
|
|
def test_has_encoding(content, encoding, expected, tmpdir):
|
|
path = tmpdir.join('path')
|
|
path.write(content, 'wb')
|
|
assert main(('--encoding', encoding, str(path))) == expected
|