-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to ScriptTest for CLI integration testing
- Loading branch information
1 parent
fea62d7
commit 40913a8
Showing
3 changed files
with
30 additions
and
7 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 |
---|---|---|
|
@@ -9,6 +9,7 @@ pytest-describe | |
pytest-expecter | ||
pytest-cov | ||
pytest-random | ||
scripttest == 1.3 | ||
|
||
# Coverage | ||
coverage | ||
|
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,35 @@ | ||
# pylint: disable=unused-variable,expression-not-assigned | ||
# pylint: disable=unused-variable,expression-not-assigned,redefined-outer-name | ||
|
||
import sys | ||
|
||
import pytest | ||
import scripttest | ||
from expecter import expect | ||
from click.testing import CliRunner | ||
|
||
from osmerge.cli import main | ||
|
||
@pytest.fixture | ||
def env(tmpdir): | ||
path = str(tmpdir.join("test")) | ||
env = scripttest.TestFileEnvironment(path) | ||
return env | ||
|
||
|
||
@pytest.fixture | ||
def cli(env): | ||
prog = sys.executable, '-m', 'osmerge' | ||
return lambda *args: env.run(*prog, *args, expect_error=True) | ||
|
||
|
||
def describe_cli(): | ||
|
||
def it_can_be_called_without_a_command(): | ||
runner = CliRunner() | ||
def it_displays_help_information(cli): | ||
cmd = cli('--help') | ||
|
||
expect(cmd.returncode) == 0 | ||
expect(cmd.stdout).contains("Usage: ") | ||
|
||
result = runner.invoke(main) | ||
def it_displays_version_information(cli): | ||
cmd = cli('--version') | ||
|
||
expect(result.exit_code) == 0 | ||
expect(cmd.returncode) == 0 | ||
expect(cmd.stdout or cmd.stderr).contains("OSMerge v0.") |