diff options
author | Alexis Hildebrandt <afh@surryhill.net> | 2015-02-20 14:07:57 +0100 |
---|---|---|
committer | Alexis Hildebrandt <afh@surryhill.net> | 2015-02-20 14:07:57 +0100 |
commit | c1e409e6934ba298cc71dfb7c6a0079d2038b09d (patch) | |
tree | 9a0210bc2da87f4174f896ceb7b0775ecc4b580a /test/DocTests.py | |
parent | 34f8c482414775cfb75de32b4181150642a4610d (diff) | |
download | fork-ledger-c1e409e6934ba298cc71dfb7c6a0079d2038b09d.tar.gz fork-ledger-c1e409e6934ba298cc71dfb7c6a0079d2038b09d.tar.bz2 fork-ledger-c1e409e6934ba298cc71dfb7c6a0079d2038b09d.zip |
[doc] Add support for additional input files
in test/DocTests.py by allowing file: and with_file: options on examples.
Diffstat (limited to 'test/DocTests.py')
-rwxr-xr-x | test/DocTests.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/test/DocTests.py b/test/DocTests.py index 6f0276da..f5746ec4 100755 --- a/test/DocTests.py +++ b/test/DocTests.py @@ -24,10 +24,12 @@ class DocTests: self.testin_token = 'command' self.testout_token = 'output' self.testdat_token = 'input' + self.testfile_token = 'file' self.validate_token = 'validate' self.validate_cmd_token = 'validate-command' self.validate_dat_token = 'validate-data' self.testwithdat_token = 'with_input' + self.testwithfile_token = 'with_file' def read_example(self): endexample = re.compile(r'^@end\s+smallexample\s*$') @@ -44,8 +46,8 @@ class DocTests: return hashlib.sha1(example.rstrip()).hexdigest()[0:7].upper() def find_examples(self): - startexample = re.compile(r'^@smallexample\s+@c\s+(%s|%s|%s)(?::([\dA-Fa-f]+|validate))?(?:,(.*))?' - % (self.testin_token, self.testout_token, self.testdat_token)) + startexample = re.compile(r'^@smallexample\s+@c\s+(%s|%s|%s|%s)(?::([\dA-Fa-f]+|validate))?(?:,(.*))?' + % (self.testin_token, self.testout_token, self.testdat_token, self.testfile_token)) while True: line = self.file.readline() self.current_line += 1 @@ -187,6 +189,14 @@ class DocTests: elif os.path.exists(os.path.join(test_input_dir, test_file)): command[findex] = os.path.join(test_input_dir, test_file) try: + convert_idx = command.index('convert') + convert_file = command[convert_idx+1] + convert_data = example[self.testfile_token][self.testfile_token] + if not os.path.exists(convert_file): + with open(convert_file, 'w') as f: + f.write(convert_data) + except ValueError: + pass error = None try: verify = subprocess.check_output(command, stderr=subprocess.STDOUT) |