mirror of
https://github.com/scito/extract_otp_secrets.git
synced 2025-12-12 17:59:48 +01:00
@@ -305,7 +305,7 @@ def open_file_or_stdout(filename):
|
|||||||
'''stdout is denoted as "-".
|
'''stdout is denoted as "-".
|
||||||
Note: Set before the following line:
|
Note: Set before the following line:
|
||||||
sys.stdout.close = lambda: None'''
|
sys.stdout.close = lambda: None'''
|
||||||
return open(filename, "w") if filename != '-' else sys.stdout
|
return open(filename, "w", encoding='utf-8') if filename != '-' else sys.stdout
|
||||||
|
|
||||||
|
|
||||||
def open_file_or_stdout_for_csv(filename):
|
def open_file_or_stdout_for_csv(filename):
|
||||||
@@ -313,7 +313,7 @@ def open_file_or_stdout_for_csv(filename):
|
|||||||
newline=''
|
newline=''
|
||||||
Note: Set before the following line:
|
Note: Set before the following line:
|
||||||
sys.stdout.close = lambda: None'''
|
sys.stdout.close = lambda: None'''
|
||||||
return open(filename, "w", newline='') if filename != '-' else sys.stdout
|
return open(filename, "w", encoding='utf-8', newline='') if filename != '-' else sys.stdout
|
||||||
|
|
||||||
|
|
||||||
def eprint(*args, **kwargs):
|
def eprint(*args, **kwargs):
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ Type: totp
|
|||||||
assert captured.out == expected_stdout
|
assert captured.out == expected_stdout
|
||||||
assert captured.err == ''
|
assert captured.err == ''
|
||||||
|
|
||||||
@mark.skipif(platform.startswith("win"), reason="This test is not supported on Windows.")
|
|
||||||
def test_extract_printqr(capsys):
|
def test_extract_printqr(capsys):
|
||||||
# Act
|
# Act
|
||||||
extract_otp_secret_keys.main(['-p', 'example_export.txt'])
|
extract_otp_secret_keys.main(['-p', 'example_export.txt'])
|
||||||
|
|||||||
@@ -140,7 +140,6 @@ Type: totp
|
|||||||
self.assertEqual(actual_output, expected_output)
|
self.assertEqual(actual_output, expected_output)
|
||||||
|
|
||||||
def test_extract_printqr(self):
|
def test_extract_printqr(self):
|
||||||
if platform.startswith("win"): self.skipTest("This test is not supported on Windows.")
|
|
||||||
out = io.StringIO()
|
out = io.StringIO()
|
||||||
with redirect_stdout(out):
|
with redirect_stdout(out):
|
||||||
extract_otp_secret_keys.main(['-p', 'example_export.txt'])
|
extract_otp_secret_keys.main(['-p', 'example_export.txt'])
|
||||||
|
|||||||
6
utils.py
6
utils.py
@@ -59,7 +59,7 @@ def remove_dir_with_files(dir):
|
|||||||
|
|
||||||
def read_csv(filename):
|
def read_csv(filename):
|
||||||
"""Returns a list of lines."""
|
"""Returns a list of lines."""
|
||||||
with open(filename, "r", newline='') as infile:
|
with open(filename, "r", encoding="utf-8", newline='') as infile:
|
||||||
lines = []
|
lines = []
|
||||||
reader = csv.reader(infile)
|
reader = csv.reader(infile)
|
||||||
for line in reader:
|
for line in reader:
|
||||||
@@ -78,7 +78,7 @@ def read_csv_str(str):
|
|||||||
|
|
||||||
def read_json(filename):
|
def read_json(filename):
|
||||||
"""Returns a list or a dictionary."""
|
"""Returns a list or a dictionary."""
|
||||||
with open(filename, "r") as infile:
|
with open(filename, "r", encoding="utf-8") as infile:
|
||||||
return json.load(infile)
|
return json.load(infile)
|
||||||
|
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ def read_json_str(str):
|
|||||||
|
|
||||||
def read_file_to_list(filename):
|
def read_file_to_list(filename):
|
||||||
"""Returns a list of lines."""
|
"""Returns a list of lines."""
|
||||||
with open(filename, "r") as infile:
|
with open(filename, "r", encoding="utf-8") as infile:
|
||||||
return infile.readlines()
|
return infile.readlines()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user