summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2014-12-30 10:37:06 -0600
committerJohn Wiegley <johnw@newartisans.com>2014-12-30 10:37:06 -0600
commitd4346ae6d84952c74584b2cdd60d0135644093a8 (patch)
tree654d16c6ef93c34b719986b835f0b7f2eb4aa8f1 /test
parentdafb99df0d2a57ae012f7b39726c3f7ef9ffd3bf (diff)
parentabf41d727a7def7d2ed9bb3a972d68f005902c98 (diff)
downloadfork-ledger-d4346ae6d84952c74584b2cdd60d0135644093a8.tar.gz
fork-ledger-d4346ae6d84952c74584b2cdd60d0135644093a8.tar.bz2
fork-ledger-d4346ae6d84952c74584b2cdd60d0135644093a8.zip
Merge pull request #358 from afh/pull/DocTests
[tests] Add examples parameter to DocTests
Diffstat (limited to 'test')
-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()