Skip to content

Commit 3cde731

Browse files
committed
Use preferred is_file and import sytax
1 parent e697989 commit 3cde731

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/electos/ballotmaker/make_ballots.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ def make_ballots(
1616
Output directory for generated PDF files
1717
Styles file for ballot formatting
1818
"""
19-
# is the EDF a JSON file?
19+
# is the EDF a file?
2020
if _edf is None:
21-
log.debug("No EDF file provided.")
21+
log.debug("No EDF file provided to make ballots.")
2222
return NO_FILE
23-
if Path.is_file(_edf) is False:
24-
log.debug(f"{_edf} is not a file")
23+
if not _edf.is_file():
24+
log.debug(f"Can't make ballots, EDF {_edf} is not a file")
2525
return NO_FILE
2626
# was a valid output directory provided?
2727
# was a styles file provided?

src/electos/ballotmaker/validate_edf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ def validate_edf(
1616
"""
1717
# is the EDF a file?
1818
if _edf is None:
19-
log.debug("No EDF file provided.")
19+
log.debug("No EDF file provided for validation.")
2020
return NO_FILE
2121
if not _edf.is_file():
22-
log.debug(f"{_edf} is not a file")
22+
log.debug(f"Can't validate, EDF {_edf} is not a file")
2323
return NO_FILE
2424

2525
ballot_style_count = read_edf(_edf)

tests/test_make_ballots.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
from pathlib import Path
22

3-
from electos.ballotmaker import make_ballots
43
from electos.ballotmaker.constants import NO_ERRORS, NO_FILE
4+
from electos.ballotmaker.make_ballots import make_ballots
55

6-
not_a_file = Path("not_a_file.json")
6+
imaginary_file = Path("imaginary_file.json")
77
test_dir = Path(__file__).parent.resolve()
88
test_file = Path("june_test_case.json")
99
full_test_path = Path(test_dir, test_file)
1010

1111

1212
def test_make_ballots():
1313
# force a no file error with Path = None
14-
assert make_ballots.make_ballots(_edf=None) == NO_FILE
15-
# ensure not_a_file is actually not a file
16-
assert Path.is_file(not_a_file) == False
17-
assert make_ballots.make_ballots(not_a_file) == NO_FILE
18-
assert Path.is_file(full_test_path)
19-
assert make_ballots.make_ballots(full_test_path) == NO_ERRORS
14+
assert make_ballots(_edf=None) == NO_FILE
15+
# ensure imaginary_file is actually not a file
16+
assert not imaginary_file.is_file()
17+
assert make_ballots(imaginary_file) == NO_FILE
18+
assert full_test_path.is_file()
19+
assert make_ballots(full_test_path) == NO_ERRORS

0 commit comments

Comments
 (0)