-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from bryant-finney/bugfix/sync-pipfile-congrats
Bugfix: sync --pipfile congratulations message
- Loading branch information
Showing
4 changed files
with
120 additions
and
22 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
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
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
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 |
---|---|---|
@@ -1,16 +1,56 @@ | ||
from vistir.compat import Path | ||
from .conftest import data | ||
from .main_test import copy_file, compare_list_of_string_kw_arg | ||
from pipenv_setup.main import cmd | ||
|
||
import pytest | ||
from vistir.compat import Path | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("source_pipfile_dirname", "update_count"), | ||
[("nasty_0", 23), ("no_original_kws_0", 23)], | ||
) | ||
def test_sync_pipfile_no_original( | ||
capsys, tmp_path, shared_datadir, source_pipfile_dirname, update_count | ||
): | ||
""" | ||
sync --pipfile should reference Pipfile (not Pipfile.lock) when printing results | ||
""" | ||
pipfile_dir = shared_datadir / source_pipfile_dirname | ||
for filename in ("Pipfile", "Pipfile.lock", "setup.py"): | ||
copy_file(pipfile_dir / filename, tmp_path) | ||
|
||
with data(str(pipfile_dir), tmp_path) as path: | ||
setup_file = path / "setup.py" # type: Path | ||
cmd(["", "sync", "--pipfile"]) | ||
text = setup_file.read_text() | ||
generated_setup = Path("setup.py") | ||
assert generated_setup.exists() | ||
generated_setup_text = generated_setup.read_text() | ||
expected_setup_text = Path("setup.py").read_text() | ||
|
||
for kw_arg_names in ("install_requires", "dependency_links"): | ||
assert compare_list_of_string_kw_arg( | ||
generated_setup_text, | ||
expected_setup_text, | ||
kw_arg_names, | ||
ordering_matters=False, | ||
) | ||
|
||
captured = capsys.readouterr() | ||
assert "Pipfile.lock" not in captured.out, captured.out | ||
assert "Pipfile" in captured.out, captured.out | ||
|
||
|
||
def test_sync_dev_no_original(tmp_path): | ||
def test_sync_dev_pipfile_no_original(tmp_path): | ||
""" | ||
sync --dev should add extras_require: {"dev": [blah]} in the absence of a extras_require keyword | ||
sync --dev --pipfile should add extras_require: {"dev": [blah]} in the absence of an | ||
extras_require keyword | ||
""" | ||
# todo: this test is too simple | ||
with data("self_0", tmp_path) as path: | ||
setup_file = path / "setup.py" # type: Path | ||
cmd(["", "sync", "--dev", "--pipfile"]) | ||
text = setup_file.read_text() | ||
assert "pytest~=5.1" in text | ||
assert "requirementslib~=1.5" in text | ||
assert "pytest~=5.1" in text, text | ||
assert "requirementslib~=1.5" in text, text |