mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Example.__init__: this cannot use assert, because that fails to trigger
in a -O run, and so test_doctest was failing under -O. Simple cause, simple cure.
This commit is contained in:
parent
8485b56216
commit
9b625d3037
2 changed files with 8 additions and 5 deletions
|
@ -478,8 +478,11 @@ class Example:
|
|||
"""
|
||||
def __init__(self, source, want, lineno):
|
||||
# Check invariants.
|
||||
assert (source[-1:] == '\n') == ('\n' in source[:-1])
|
||||
assert want == '' or want[-1] == '\n'
|
||||
if (source[-1:] == '\n') != ('\n' in source[:-1]):
|
||||
raise AssertionError("source must end with newline iff "
|
||||
"source contains more than one line")
|
||||
if want and want[-1] != '\n':
|
||||
raise AssertionError("non-empty want must end with newline")
|
||||
# Store properties.
|
||||
self.source = source
|
||||
self.want = want
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue