Kaydet (Commit) b12cb6a5 authored tarafından Serhiy Storchaka's avatar Serhiy Storchaka

Issue #19535: Fixed test_docxmlrpc, test_functools, test_inspect, and

test_statistics when python is run with -OO.
......@@ -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())
......
......@@ -1126,6 +1126,7 @@ class TestSingleDispatch(unittest.TestCase):
"Simple test"
return "Test"
self.assertEqual(g.__name__, "g")
if sys.flags.optimize < 2:
self.assertEqual(g.__doc__, "Simple test")
@unittest.skipUnless(decimal, 'requires _decimal')
......
......@@ -2529,6 +2529,7 @@ class TestMain(unittest.TestCase):
# Just a quick sanity check on the output
self.assertIn(module.__name__, output)
self.assertIn(module.__file__, output)
if not sys.flags.optimize:
self.assertIn(module.__cached__, output)
self.assertEqual(err, b'')
......
......@@ -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)
......
......@@ -112,6 +112,9 @@ Library
Tests
-----
- Issue #19535: Fixed test_docxmlrpc, test_functools, test_inspect, and
test_statistics when python is run with -OO.
- Issue #19926: Removed unneeded test_main from test_abstract_numbers.
Patch by Vajrasky Kok.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment