Skip to content

Commit

Permalink
fixed inline tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvin Wan committed Jan 1, 2018
1 parent 20e34d4 commit a46381b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
5 changes: 1 addition & 4 deletions samples/sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ hello world
20
*/

CREATE TABLE LePoop AS -- > SELECT "hai" || ! => hai!
CREATE TABLE LePoop AS -- > SELECT "hai" || "!"; => hai!
SELECT 20 AS burd, 10 AS duck, 5 AS goose UNION
SELECT 12, 2, 3 UNION
SELECT 31, 34, 0;

-- >>> SELECT burd FROM LePoop WHERE goose > 2 LIMIT 1;
-- 20
2 changes: 1 addition & 1 deletion uniexpect/configs/scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'inline_comments': False
},
{
'input_prefix': '; > ',
'input_prefix': '> ',
'output_prefix': '=>',
'one-liner': True,
'block_comments': True,
Expand Down
7 changes: 4 additions & 3 deletions uniexpect/expect.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ def extract_comments(code, settings):
# extract all inline comments
inlines = []
for start in settings.inline_comments:
start = re.escape(start)
inline = re.compile('{}[^\n]+'.format(start))
inlines.extend(inline.findall(code))
inlines.extend([line[len(start):] for line in inline.findall(code)])
decommented_code = inline.sub('', decommented_code)

return blocks, inlines, decommented_code
Expand Down Expand Up @@ -95,8 +94,10 @@ def extract_tests(*args):
inline = inline.strip()
for test in inline_tests:
if inline.startswith(test['input_prefix']):
inline_body = inline[len(test['input_prefix']):]
suites.append(
[split(inline, test['output_prefix']) + [test]])
[split(inline_body, test['output_prefix']) + [test]])
break
return suites, code

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion uniexpect/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def main():
if not correct or args.verbose:
print(test_output.format(**output))
if length == passed:
print('\nAll passed!\n')
print('\nAll passed! (%d/%d)\n' % (passed, length))
else:
print('\nPassed', passed, 'of', length, 'tests.\n')
print(hbar)
Expand Down

0 comments on commit a46381b

Please sign in to comment.