-
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.
- Loading branch information
Showing
3 changed files
with
39 additions
and
52 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,35 @@ | ||
from functools import wraps | ||
from pathlib import Path | ||
|
||
from click.testing import CliRunner | ||
|
||
|
||
def read_all(filename): | ||
return Path(filename).read_text() | ||
|
||
|
||
def with_isolated_runner(fn): | ||
""" | ||
Run *fn* within an isolated filesystem and add the kwarg *runner* to its | ||
arguments. | ||
""" | ||
|
||
@wraps(fn) | ||
def test(*args, **kw): | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(): | ||
return fn(*args, runner=runner, **kw) | ||
|
||
return test | ||
|
||
|
||
def setup_simple_project(config=None, mkdir_newsfragments=True): | ||
if config is None: | ||
config = "[tool.towncrier]\n" 'package = "foo"\n' | ||
|
||
Path("pyproject.toml").write_text(config) | ||
Path("foo").mkdir() | ||
Path("foo/__init__.py").write_text('__version__ = "1.2.3"\n') | ||
|
||
if mkdir_newsfragments: | ||
Path("foo/newsfragments").mkdir() |
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