summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-12-08 16:16:18 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-12-08 16:16:18 (GMT)
commitb12cb6a5509dbaafa05706dd64861bfef9fa42d7 (patch)
treed0021701f3d6d5cba2c293bf769c861e39f6f9b1 /Lib
parentca616a2709951f2ef8534aaa5933af4cc9d1594d (diff)
parent3e60a9d602c85b738dc74a3c8a196650822e8619 (diff)
downloadcpython-b12cb6a5509dbaafa05706dd64861bfef9fa42d7.zip
cpython-b12cb6a5509dbaafa05706dd64861bfef9fa42d7.tar.gz
cpython-b12cb6a5509dbaafa05706dd64861bfef9fa42d7.tar.bz2
Issue #19535: Fixed test_docxmlrpc, test_functools, test_inspect, and
test_statistics when python is run with -OO.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_docxmlrpc.py6
-rw-r--r--Lib/test/test_functools.py3
-rw-r--r--Lib/test/test_inspect.py3
-rw-r--r--Lib/test/test_statistics.py3
4 files changed, 11 insertions, 4 deletions
diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py
index 7086d9a..cb6366c 100644
--- a/Lib/test/test_docxmlrpc.py
+++ b/Lib/test/test_docxmlrpc.py
@@ -202,10 +202,12 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
""" Test that annotations works as expected """
self.client.request("GET", "/")
response = self.client.getresponse()
+ docstring = (b'' if sys.flags.optimize >= 2 else
+ b'<dd><tt>Use&nbsp;function&nbsp;annotations.</tt></dd>')
self.assertIn(
(b'<dl><dt><a name="-annotation"><strong>annotation</strong></a>'
- b'(x: int)</dt><dd><tt>Use&nbsp;function&nbsp;annotations.</tt>'
- b'</dd></dl>\n<dl><dt><a name="-method_annotation"><strong>'
+ b'(x: int)</dt>' + docstring + b'</dl>\n'
+ b'<dl><dt><a name="-method_annotation"><strong>'
b'method_annotation</strong></a>(x: bytes)</dt></dl>'),
response.read())
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index d044237..75ae7f3 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -1126,7 +1126,8 @@ class TestSingleDispatch(unittest.TestCase):
"Simple test"
return "Test"
self.assertEqual(g.__name__, "g")
- self.assertEqual(g.__doc__, "Simple test")
+ if sys.flags.optimize < 2:
+ self.assertEqual(g.__doc__, "Simple test")
@unittest.skipUnless(decimal, 'requires _decimal')
@support.cpython_only
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 365f592..520bf0e 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -2529,7 +2529,8 @@ class TestMain(unittest.TestCase):
# Just a quick sanity check on the output
self.assertIn(module.__name__, output)
self.assertIn(module.__file__, output)
- self.assertIn(module.__cached__, output)
+ if not sys.flags.optimize:
+ self.assertIn(module.__cached__, output)
self.assertEqual(err, b'')
diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py
index ee585e2..3d30d88 100644
--- a/Lib/test/test_statistics.py
+++ b/Lib/test/test_statistics.py
@@ -8,6 +8,7 @@ import decimal
import doctest
import math
import random
+import sys
import types
import unittest
@@ -625,6 +626,8 @@ class GlobalsTest(unittest.TestCase):
class DocTests(unittest.TestCase):
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -OO and above")
def test_doc_tests(self):
failed, tried = doctest.testmod(statistics)
self.assertGreater(tried, 0)