summaryrefslogtreecommitdiff
path: root/test/DocTests.py
diff options
context:
space:
mode:
authorAlexis Hildebrandt <afh@surryhill.net>2014-12-30 10:44:06 +0100
committerAlexis Hildebrandt <afh@surryhill.net>2014-12-30 11:15:23 +0100
commitabf41d727a7def7d2ed9bb3a972d68f005902c98 (patch)
treea7155731243ec9eda47f4dce924392c5049b3b8a /test/DocTests.py
parent66ce4ac48f88b81eab1a2c04eeef83ee4fa06335 (diff)
downloadfork-ledger-abf41d727a7def7d2ed9bb3a972d68f005902c98.tar.gz
fork-ledger-abf41d727a7def7d2ed9bb3a972d68f005902c98.tar.bz2
fork-ledger-abf41d727a7def7d2ed9bb3a972d68f005902c98.zip
[tests] Add examples parameter to DocTests
to test the given examples only instead of every example.
Diffstat (limited to 'test/DocTests.py')
-rwxr-xr-xtest/DocTests.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/DocTests.py b/test/DocTests.py
index dbd24634..ea32608e 100755
--- a/test/DocTests.py
+++ b/test/DocTests.py
@@ -16,6 +16,7 @@ class DocTests:
self.ledger = os.path.abspath(args.ledger)
self.sourcepath = os.path.abspath(args.file)
self.verbose = args.verbose
+ self.tests = args.examples
self.examples = dict()
self.test_files = list()
@@ -133,7 +134,14 @@ class DocTests:
def test_examples(self):
failed = set()
- for test_id in self.examples:
+ tests = self.examples.keys()
+ if self.tests:
+ tests = list(set(self.tests).intersection(tests))
+ temp = list(set(self.tests).difference(tests))
+ if len(temp) > 0:
+ print >> sys.stderr, 'Skipping non-existent examples: %s' % ', '.join(temp)
+
+ for test_id in tests:
validation = False
if "validate-data" in self.examples[test_id] or "validate-command" in self.examples[test_id]:
validation = True
@@ -213,7 +221,7 @@ class DocTests:
if __name__ == "__main__":
def getargs():
- parser = argparse.ArgumentParser(description='DocTests', prefix_chars='-')
+ parser = argparse.ArgumentParser(prog='DocTests', description='Test ledger examples from the documentation', prefix_chars='-')
parser.add_argument('-v', '--verbose',
dest='verbose',
action='count',
@@ -230,6 +238,11 @@ if __name__ == "__main__":
action='store',
required=True,
help='the texinfo documentation file to run the examples from')
+ parser.add_argument('examples',
+ metavar='EXAMPLE',
+ type=str,
+ nargs='*',
+ help='the examples to test')
return parser.parse_args()
args = getargs()