mirror of
https://github.com/scito/extract_otp_secrets.git
synced 2025-12-13 18:30:26 +01:00
fix finput encoding problem on Windows
This commit is contained in:
@@ -335,7 +335,7 @@ def get_otp_urls_from_file(filename: str, args: Args) -> OtpUrls:
|
||||
|
||||
def read_lines_from_text_file(filename: str) -> list[str]:
|
||||
if verbose: print(f"Reading lines of {filename}")
|
||||
finput = fileinput.input(filename)
|
||||
finput = fileinput.input(filename, encoding='utf-8')
|
||||
try:
|
||||
lines = []
|
||||
for line in (line.strip() for line in finput):
|
||||
|
||||
@@ -36,6 +36,10 @@ from utils import (file_exits, quick_and_dirty_workaround_encoding_problem,
|
||||
qreader_available: bool = extract_otp_secrets.qreader_available
|
||||
|
||||
|
||||
# Quickfix comment
|
||||
#@pytest.mark.skipif(sys.platform.startswith("win") or not qreader_available or sys.implementation.name == 'pypy', reason="Quickfix")
|
||||
|
||||
|
||||
def test_extract_stdout(capsys: pytest.CaptureFixture[str]) -> None:
|
||||
# Act
|
||||
extract_otp_secrets.main(['example_export.txt'])
|
||||
@@ -91,7 +95,6 @@ def test_extract_stdin_empty(capsys: pytest.CaptureFixture[str], monkeypatch: py
|
||||
assert captured.err == 'WARN: stdin is empty\n'
|
||||
|
||||
|
||||
# @pytest.mark.skipif(not qreader_available, reason='Test if cv2 and qreader are not available.')
|
||||
def test_extract_empty_file_no_qreader(capsys: pytest.CaptureFixture[str]) -> None:
|
||||
if qreader_available:
|
||||
# Act
|
||||
@@ -351,7 +354,6 @@ def test_normalize_bytes() -> None:
|
||||
'Before\\\\302\\\\277\\\\303\nname: enc: \\302\\277\\303\\244\\303\\204\\303\\251\\303\\211?\nAfter') == 'Before\\\\302\\\\277\\\\303\nname: enc: ¿äÄéÉ?\nAfter'
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Avoid encoding problems")
|
||||
def test_extract_verbose(capsys: pytest.CaptureFixture[str], relaxed: bool) -> None:
|
||||
# Act
|
||||
extract_otp_secrets.main(['-v', 'example_export.txt'])
|
||||
|
||||
@@ -171,7 +171,7 @@ Type: totp
|
||||
self.assertEqual(count_files_in_dir('testout/qr'), 6)
|
||||
|
||||
def test_extract_verbose(self) -> None:
|
||||
if sys.implementation.name == 'pypy' or sys.platform.startswith("win"):
|
||||
if sys.implementation.name == 'pypy':
|
||||
self.skipTest("Avoid encoding problems")
|
||||
out = io.StringIO()
|
||||
with redirect_stdout(out):
|
||||
|
||||
Reference in New Issue
Block a user