Skip to content

Commit

Permalink
test_cli: replaced 'read_text()' and 'write_text()' to avoid encoding…
Browse files Browse the repository at this point in the history
… errors (#6)
  • Loading branch information
juk0de committed Jul 18, 2024
1 parent f862c8e commit d21248a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import tempfile
import json
from pathlib import Path
import shutil


def test_convert_to_stdout() -> None:
Expand Down Expand Up @@ -33,7 +34,7 @@ def test_convert() -> None:
with tempfile.TemporaryDirectory() as tmpdir:
temp_mtf_file = Path(tmpdir) / mtf_file.name
temp_json_file = temp_mtf_file.with_suffix('.json')
temp_mtf_file.write_text(mtf_file.read_text())
shutil.copy(mtf_file, temp_mtf_file)

result = subprocess.run(
["poetry", "run", "mtf2json", "--mtf-file", str(temp_mtf_file), "--convert"],
Expand Down Expand Up @@ -88,7 +89,7 @@ def test_convert_directory() -> None:
temp_mtf_dir.mkdir(parents=True, exist_ok=True)
for mtf_file in mtf_dir.glob("*.mtf"):
temp_mtf_file = temp_mtf_dir / mtf_file.name
temp_mtf_file.write_text(mtf_file.read_text())
shutil.copy(mtf_file, temp_mtf_file)

result = subprocess.run(
["poetry", "run", "mtf2json", "--mtf-dir", str(temp_mtf_dir)],
Expand Down Expand Up @@ -125,7 +126,7 @@ def test_convert_directory_recursive() -> None:
# copy the same files into all subdirs (no problem for this testcase)
for mtf_file in mtf_dir.glob("*.mtf"):
temp_mtf_file = temp_mtf_dir / subdir / mtf_file.name
temp_mtf_file.write_text(mtf_file.read_text())
shutil.copy(mtf_file, temp_mtf_file)

result = subprocess.run(
["poetry", "run", "mtf2json", "--mtf-dir", str(temp_mtf_dir), "--recursive"],
Expand Down Expand Up @@ -163,7 +164,7 @@ def test_convert_directory_recursive_to_json_dir() -> None:
(temp_mtf_dir / subdir).mkdir(parents=True, exist_ok=True)
for mtf_file in mtf_dir.glob("*.mtf"):
temp_mtf_file = temp_mtf_dir / subdir / mtf_file.name
temp_mtf_file.write_text(mtf_file.read_text())
shutil.copy(mtf_file, temp_mtf_file)

result = subprocess.run(
["poetry", "run", "mtf2json", "--mtf-dir", str(temp_mtf_dir), "--json-dir", str(temp_json_dir), "--recursive"],
Expand Down

0 comments on commit d21248a

Please sign in to comment.