Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jnrowe/shell-doctest
shelldoctest is Doctest/UnitTest for shell (mirror of Google Code project)
https://github.com/jnrowe/shell-doctest
Last synced: 5 days ago
JSON representation
shelldoctest is Doctest/UnitTest for shell (mirror of Google Code project)
- Host: GitHub
- URL: https://github.com/jnrowe/shell-doctest
- Owner: JNRowe
- License: bsd-3-clause
- Created: 2011-04-05T12:32:07.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2011-04-05T12:32:44.000Z (almost 14 years ago)
- Last Synced: 2023-04-14T17:08:48.342Z (almost 2 years ago)
- Language: Python
- Homepage: http://code.google.com/p/shell-doctest/
- Size: 113 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: CHANGES
- License: LICENSE
Awesome Lists containing this project
README
========
Overview
========shelldoctest is Doctest/UnitTest for shell.
Doctest for shell
=================Usage
-----test.py::
#!/usr/bin/env python
"""
$ echo TEST
TEST
$ LANG=C date -u -r 0
Thu Jan 1 00:00:00 UTC 1970
"""if __name__ == "__main__":
import shelldoctest
shelldoctest.testmod()Shell Doctest Syntax
--------------------Basic::
$
Multi Lines::
$
.
with Label::
[]
$
Run on Remote Host::
@
$
[]
@
$
Run by User::
@
$
[]
@
$
Checking STDERR::
$
()
Management Tool
---------------`shell-doctest` command::
$ shell-doctest test ...
$ shell-doctest test ...
$ shell-doctest test ... ...
Examples
~~~~~~~~test.py::
"""
$ echo TEST
TEST[#1]
$ echo TEST1
TEST1[#2]
$ echo TEST2
TEST2
"""Run TEST::
$ shell-doctest test ./test.py
$ shell-doctest --verbose=2 test ./test.py
Module:test.py
Label:None
Label:#1
Label:#2$ shell-doctest --verbose=2 test ./test.py #2 #1
Module:test.py
Label:#2
Label:#1$ shell-doctest --verbose=3 test ./test.py #2
New verbose level is 3
Module:manage.py
Label:#2
Trying:
echo TEST2
Expecting:
TEST2
ok
1 items passed all tests:
1 tests in manage
1 tests in 3 items.
1 passed and 0 failed.
Test passed.UnitTest
========::
from doctest import ELLIPSIS
from shelldoctest.shellunittest import Connection, TestCase
host = "localhost:22"
class MyTest(TestCase):
c1 = Connection(host)
c2 = Connection(host)def test(self):
self.assertOutput(self.c1, "pwd", "/.../...\n", ELLIPSIS)
self.c1("cd /", None)
self.assertOutput(self.c2, "pwd", "/.../...\n", ELLIPSIS)
self.assertOutput(self.c1, "pwd", "/\n")