-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
7f6cc81
commit 9c6191f
Showing
5 changed files
with
37 additions
and
0 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,37 @@ | ||
from unittest import mock | ||
|
||
from pytest import MonkeyPatch | ||
|
||
import packaged.cli | ||
|
||
|
||
def test_cli(monkeypatch: MonkeyPatch) -> None: | ||
"""Ensures that CLI passes args to `create_package()` properly.""" | ||
# Don't want to run makeself while testing CLI | ||
monkeypatch.setattr(packaged.cli, "ensure_makeself", lambda: None) | ||
|
||
with mock.patch.object(packaged.cli, "create_package") as mocked: | ||
packaged.cli.cli(["./foo", "pip install foo", "python -m foo"]) | ||
|
||
# source_directory is None | ||
mocked.assert_called_with(None, "./foo", "pip install foo", "python -m foo") | ||
|
||
with mock.patch.object(packaged.cli, "create_package") as mocked: | ||
packaged.cli.cli( | ||
[ | ||
"./bar", | ||
"pip install -rrequirements.txt", | ||
"python src/mypackage/cli.py", | ||
"./mypackage", | ||
] | ||
) | ||
|
||
# source_directory is `./mypackage` | ||
mocked.assert_called_with( | ||
mock.ANY, | ||
"./bar", | ||
"pip install -rrequirements.txt", | ||
"python src/mypackage/cli.py", | ||
) | ||
args = mocked.call_args[0] | ||
assert args[0].endswith("/mypackage") |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.