diff options
author | Tim Peters <tim.peters@gmail.com> | 2004-08-04 20:04:32 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2004-08-04 20:04:32 (GMT) |
commit | 9b625d3037815a6753fca21ad19711a92bebec54 (patch) | |
tree | fb81ecf74c56e24c7cd5a6e0a349042a5383cea5 /Lib/doctest.py | |
parent | 8485b562164304d068dfac4cee0f5108251eda55 (diff) | |
download | cpython-9b625d3037815a6753fca21ad19711a92bebec54.zip cpython-9b625d3037815a6753fca21ad19711a92bebec54.tar.gz cpython-9b625d3037815a6753fca21ad19711a92bebec54.tar.bz2 |
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.
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r-- | Lib/doctest.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index ecf0e1a..86d1782 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -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 |