Skip to content

Commit

Permalink
Fix test overwriting a test configuration file (#648)
Browse files Browse the repository at this point in the history
Running `pytest tests/test_file_operations.py` was overwriting a test
configuration file. Fixes the offending test and adds a missing
`assert` statement.

[ committed by @MattToast ]
[ reviewed by @juliaputko ]
  • Loading branch information
MattToast authored Jul 31, 2024
1 parent bd21957 commit a2c1251
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/test_file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,12 @@ def test_configure_op(test_dir, fileutils, param_dict, error_type):
assert filecmp.cmp(written, correct)


def test_configure_invalid_tags(fileutils):
def test_configure_invalid_tags(fileutils, test_dir):
"""Test configure operation with an invalid tag"""
tagged_file = fileutils.get_test_conf_path(
osp.join("generator_files", "easy", "marked", "invalidtag.txt")
)
generator_files = pathlib.Path(fileutils.get_test_conf_path("generator_files"))
tagged_file = generator_files / "easy/marked/invalidtag.txt"
correct_file = generator_files / "easy/correct/invalidtag.txt"
target_file = pathlib.Path(test_dir, "target.txt")

tag = ";"
param_dict = {"VALID": "valid"}
Expand All @@ -560,11 +561,12 @@ def test_configure_invalid_tags(fileutils):
# Encode the pickled dictionary with Base64
encoded_dict = base64.b64encode(pickled_dict).decode("ascii")
parser = get_parser()
cmd = f"configure {tagged_file} {tagged_file} {tag} {encoded_dict}"
cmd = f"configure {tagged_file} {target_file} {tag} {encoded_dict}"
args = cmd.split()
ns = parser.parse_args(args)

file_operations.configure(ns)
assert filecmp.cmp(correct_file, target_file)


def test_configure_not_absolute():
Expand Down

0 comments on commit a2c1251

Please sign in to comment.