-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from pathlib import Path | ||
from argparse import ArgumentTypeError | ||
|
||
import pytest | ||
|
||
from dp_creator_ii import get_arg_parser, existing_csv | ||
|
||
|
||
def test_help(): | ||
help = ( | ||
get_arg_parser() | ||
.format_help() | ||
# argparse doesn't actually know the name of the script | ||
# and inserts the name of the running program instead. | ||
.replace("__main__.py", "dp-creator-ii") | ||
.replace("pytest", "dp-creator-ii") | ||
# Text is different under Python 3.9: | ||
.replace("optional arguments:", "options:") | ||
) | ||
print(help) | ||
|
||
readme_md = (Path(__file__).parent.parent.parent / "README.md").read_text() | ||
assert help in readme_md | ||
|
||
|
||
def test_arg_validation_no_file(): | ||
with pytest.raises(ArgumentTypeError, match="No such file: no-such-file"): | ||
existing_csv("no-such-file") | ||
|
||
|
||
def test_arg_validation_not_csv(): | ||
with pytest.raises(ArgumentTypeError, match='Must have ".csv" extension:'): | ||
existing_csv(Path(__file__).parent / "fixtures" / "fake.ipynb") | ||
|
||
|
||
def test_arg_validation_works(): | ||
path = existing_csv(Path(__file__).parent / "fixtures" / "fake.csv") | ||
assert path.name == "fake.csv" |
This file was deleted.
Oops, something went wrong.