-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More compact remove_files and use with_isolated_runner for new tests
- Loading branch information
Showing
2 changed files
with
55 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -407,39 +407,38 @@ def test_no_confirmation(self): | |
self.assertFalse(os.path.isfile(fragment_path1)) | ||
self.assertFalse(os.path.isfile(fragment_path2)) | ||
|
||
def test_keep_fragments(self): | ||
@with_isolated_runner | ||
def test_keep_fragments(self, runner): | ||
""" | ||
The `--keep` option will build the full final news file | ||
without deleting the fragment files and without | ||
any extra CLI interaction or confirmation. | ||
""" | ||
runner = CliRunner() | ||
|
||
with runner.isolated_filesystem(): | ||
setup_simple_project() | ||
fragment_path1 = "foo/newsfragments/123.feature" | ||
fragment_path2 = "foo/newsfragments/124.feature.rst" | ||
with open(fragment_path1, "w") as f: | ||
f.write("Adds levitation") | ||
with open(fragment_path2, "w") as f: | ||
f.write("Extends levitation") | ||
setup_simple_project() | ||
fragment_path1 = "foo/newsfragments/123.feature" | ||
fragment_path2 = "foo/newsfragments/124.feature.rst" | ||
with open(fragment_path1, "w") as f: | ||
f.write("Adds levitation") | ||
with open(fragment_path2, "w") as f: | ||
f.write("Extends levitation") | ||
|
||
call(["git", "init"]) | ||
call(["git", "config", "user.name", "user"]) | ||
call(["git", "config", "user.email", "[email protected]"]) | ||
call(["git", "add", "."]) | ||
call(["git", "commit", "-m", "Initial Commit"]) | ||
call(["git", "init"]) | ||
call(["git", "config", "user.name", "user"]) | ||
call(["git", "config", "user.email", "[email protected]"]) | ||
call(["git", "add", "."]) | ||
call(["git", "commit", "-m", "Initial Commit"]) | ||
|
||
result = runner.invoke(_main, ["--date", "01-01-2001", "--keep"]) | ||
result = runner.invoke(_main, ["--date", "01-01-2001", "--keep"]) | ||
|
||
self.assertEqual(0, result.exit_code) | ||
# The NEWS file is created. | ||
# So this is not just `--draft`. | ||
self.assertTrue(os.path.isfile("NEWS.rst")) | ||
self.assertTrue(os.path.isfile(fragment_path1)) | ||
self.assertTrue(os.path.isfile(fragment_path2)) | ||
self.assertEqual(0, result.exit_code) | ||
# The NEWS file is created. | ||
# So this is not just `--draft`. | ||
self.assertTrue(os.path.isfile("NEWS.rst")) | ||
self.assertTrue(os.path.isfile(fragment_path1)) | ||
self.assertTrue(os.path.isfile(fragment_path2)) | ||
|
||
def test_yes_keep_error(self): | ||
@with_isolated_runner | ||
def test_yes_keep_error(self, runner): | ||
""" | ||
It will fail to perform any action when the | ||
conflicting --keep and --yes options are provided. | ||
|
@@ -448,28 +447,25 @@ def test_yes_keep_error(self): | |
to make sure both orders are validated since click triggers the validator | ||
in the order it parses the command line. | ||
""" | ||
runner = CliRunner() | ||
|
||
with runner.isolated_filesystem(): | ||
setup_simple_project() | ||
fragment_path1 = "foo/newsfragments/123.feature" | ||
fragment_path2 = "foo/newsfragments/124.feature.rst" | ||
with open(fragment_path1, "w") as f: | ||
f.write("Adds levitation") | ||
with open(fragment_path2, "w") as f: | ||
f.write("Extends levitation") | ||
|
||
call(["git", "init"]) | ||
call(["git", "config", "user.name", "user"]) | ||
call(["git", "config", "user.email", "[email protected]"]) | ||
call(["git", "add", "."]) | ||
call(["git", "commit", "-m", "Initial Commit"]) | ||
|
||
result = runner.invoke(_main, ["--date", "01-01-2001", "--yes", "--keep"]) | ||
self.assertEqual(1, result.exit_code) | ||
setup_simple_project() | ||
fragment_path1 = "foo/newsfragments/123.feature" | ||
fragment_path2 = "foo/newsfragments/124.feature.rst" | ||
with open(fragment_path1, "w") as f: | ||
f.write("Adds levitation") | ||
with open(fragment_path2, "w") as f: | ||
f.write("Extends levitation") | ||
|
||
call(["git", "init"]) | ||
call(["git", "config", "user.name", "user"]) | ||
call(["git", "config", "user.email", "[email protected]"]) | ||
call(["git", "add", "."]) | ||
call(["git", "commit", "-m", "Initial Commit"]) | ||
|
||
result = runner.invoke(_main, ["--date", "01-01-2001", "--yes", "--keep"]) | ||
self.assertEqual(1, result.exit_code) | ||
|
||
result = runner.invoke(_main, ["--date", "01-01-2001", "--keep", "--yes"]) | ||
self.assertEqual(1, result.exit_code) | ||
result = runner.invoke(_main, ["--date", "01-01-2001", "--keep", "--yes"]) | ||
self.assertEqual(1, result.exit_code) | ||
|
||
def test_confirmation_says_no(self): | ||
""" | ||
|