Created
July 24, 2012 02:43
-
-
Save t2y/3167682 to your computer and use it in GitHub Desktop.
simple plugin for shelldoctest with pytest, though this script reports only its result
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
import pytest | |
import shelldoctest | |
# use this if you run only shelldoctest | |
#def pytest_addoption(parser): | |
# parser.addoption("--shelldoctest", action="store_true", | |
# help="run shell-doctest") | |
# | |
#def pytest_runtest_setup(item): | |
# if not isinstance(item, item.Function): | |
# return | |
# if item.config.option.shelldoctest \ | |
# and not hasattr(item.obj, 'shelldoctest'): | |
# pytest.skip("test with shelldoctest only") | |
def pytest_generate_tests(metafunc): | |
if hasattr(metafunc.function, "shelldoctest"): | |
result = shelldoctest.testmod(metafunc.module) | |
metafunc.parametrize("result", [result]) |
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
import pytest | |
@pytest.mark.shelldoctest | |
def test_sampletest(result): | |
""" | |
$ echo TEST | |
TEST | |
[#1] | |
$ echo TEST1 | |
TEST1 | |
[#2] | |
$ echo TEST2 | |
TEST3 Failed!!! | |
""" | |
assert result.failed == 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment