fix: robustify EndSetup detection and add warning test
This commit is contained in:
parent
ca895889f9
commit
fc57b48eb8
@ -34,7 +34,7 @@ def process_stream(lines, account_code):
|
||||
|
||||
for line in lines:
|
||||
stripped = line.rstrip(b'\r\n')
|
||||
if not injected and (stripped == b'%%EndSetup' or stripped.startswith(b'%%Page:')):
|
||||
if not injected and (stripped.rstrip() == b'%%EndSetup' or stripped.startswith(b'%%Page:')):
|
||||
yield inject
|
||||
injected = True
|
||||
yield line
|
||||
|
||||
@ -79,3 +79,9 @@ class TestProcessStream:
|
||||
ps = "%!PS\n%%BeginSetup\n%%EndSetup\nshowpage\n"
|
||||
result = self._collect(ps, "00012345")
|
||||
assert b"showpage\n" in result
|
||||
|
||||
def test_warns_when_no_injection_point(self, capsys):
|
||||
ps = "%!PS\nshowpage\n"
|
||||
self._collect(ps, "00012345")
|
||||
captured = capsys.readouterr()
|
||||
assert "WARNING" in captured.err
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user