-
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.
Merge pull request #37 from TGoddessana/dev
Updates to test code writing, mypy and flake8 checks
- Loading branch information
Showing
9 changed files
with
129 additions
and
13 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from importlib.metadata import version | ||
|
||
import pytest | ||
|
||
from flask_moreshell.shells import BPythonShell | ||
|
||
|
||
@pytest.fixture | ||
def bpython_shell(): | ||
return BPythonShell() | ||
|
||
|
||
def test_get_shell_name(bpython_shell): | ||
assert bpython_shell.get_shell_name() == "BPython" | ||
|
||
|
||
def test_get_shell_version(bpython_shell): | ||
assert bpython_shell.get_shell_version() == version("bpython") |
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,18 @@ | ||
import pytest | ||
|
||
from flask_moreshell.shells import IpythonShell | ||
|
||
|
||
@pytest.fixture | ||
def ipython_shell(): | ||
return IpythonShell() | ||
|
||
|
||
def test_get_shell_name(ipython_shell): | ||
assert ipython_shell.get_shell_name() == "IPython" | ||
|
||
|
||
def test_get_shell_version(ipython_shell): | ||
from IPython import __version__ | ||
|
||
assert ipython_shell.get_shell_version() == __version__ |
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 importlib.metadata import version | ||
|
||
import pytest | ||
from flask import Flask | ||
|
||
from flask_moreshell.shells import PTPythonShell | ||
|
||
|
||
@pytest.fixture | ||
def app(): | ||
app = Flask(__name__) | ||
app.config["TESTING"] = True | ||
return app | ||
|
||
|
||
@pytest.fixture | ||
def ptpython_shell(): | ||
return PTPythonShell() | ||
|
||
|
||
def test_get_shell_name(ptpython_shell): | ||
assert ptpython_shell.get_shell_name() == "PTPython" | ||
|
||
|
||
def test_get_shell_version(ptpython_shell): | ||
assert ptpython_shell.get_shell_version() == version("ptpython") | ||
|
||
|
||
def test_load(ptpython_shell, monkeypatch, capsys, app): | ||
with app.app_context(): | ||
ptpython_shell.load() | ||
|
||
stdout = capsys.readouterr().out | ||
|
||
assert ptpython_shell.get_shell_name() in stdout | ||
assert ptpython_shell.get_shell_version() in stdout | ||
assert "PTPython" in stdout |
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,17 +1,46 @@ | ||
"""Test cases for the __main__ module.""" | ||
import pytest | ||
from click.testing import CliRunner | ||
from flask import Flask | ||
|
||
from flask_moreshell import shell | ||
|
||
|
||
@pytest.fixture | ||
def runner() -> CliRunner: | ||
"""Fixture for invoking command-line interfaces.""" | ||
def app(): | ||
app = Flask(__name__) | ||
app.config["TESTING"] = True | ||
return app | ||
|
||
|
||
@pytest.fixture | ||
def runner(app): | ||
return CliRunner() | ||
|
||
|
||
def test_main_succeeds(runner: CliRunner) -> None: | ||
"""It exits with a status code of zero.""" | ||
result = runner.invoke(shell) | ||
def test_ipython_shell(runner, app): | ||
with app.app_context(): | ||
result = runner.invoke(shell, ["--shelltype", "ipython"]) | ||
assert result.exit_code == 0 | ||
assert "IPython" in result.output | ||
|
||
|
||
# def test_bpython_shell(runner, app): | ||
# with app.app_context(): | ||
# result = runner.invoke(shell, ["--shelltype", "bpython"]) | ||
# assert result.output == "" | ||
# assert result.exit_code == 0 | ||
# assert "BPython" in result.output | ||
|
||
|
||
def test_pypython_shell(runner, app): | ||
with app.app_context(): | ||
result = runner.invoke(shell, ["--shelltype", "ptpython"]) | ||
assert result.exit_code == 0 | ||
assert "PTPython" in result.output | ||
|
||
|
||
def test_python_shell(runner, app): | ||
with app.app_context(): | ||
result = runner.invoke(shell, ["--shelltype", "python"]) | ||
assert result.exit_code == 0 | ||
assert "Python" in result.output |