Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cram/_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def test(lines, shell='/bin/sh', indent=2, testname=None, env=None,
refout, postout = [], []
i = pos = prepos = -1
stdin = []
in_test = False
for i, line in enumerate(lines):
if not line.endswith(b'\n'):
line += b'\n'
Expand All @@ -129,11 +130,14 @@ def test(lines, shell='/bin/sh', indent=2, testname=None, env=None,
pos = i
stdin.append(b'echo %s %d $?\n' % (salt, i))
stdin.append(line[len(cmdline):])
in_test = True
elif line.startswith(conline):
after.setdefault(prepos, []).append(line)
stdin.append(line[len(conline):])
elif not line.startswith(indent):
in_test = True
elif not line.startswith(indent) or not in_test:
after.setdefault(pos, []).append(line)
in_test = False
stdin.append(b'echo %s %d $?\n' % (salt, i + 1))

output, retcode = execute(shell + ['-'], stdin=b''.join(stdin),
Expand Down
2 changes: 2 additions & 0 deletions tests/test.t
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ Custom indentation:
>
> $ echo foo
> bar
>
> Nor is this!
> EOF
$ cram --indent=4 indent.t
.
Expand Down