bpo-37685: Use singletons ALWAYS_EQ and NEVER_EQ in more tests. (GH-15167)

This commit is contained in:
Serhiy Storchaka 2019-08-08 08:43:18 +03:00 committed by GitHub
parent 662db125cd
commit 7d44e7a456
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 30 additions and 57 deletions

View file

@ -25,7 +25,7 @@ except ImportError:
ThreadPoolExecutor = None
from test.support import run_unittest, TESTFN, DirsOnSysPath, cpython_only
from test.support import MISSING_C_DOCSTRINGS, cpython_only
from test.support import MISSING_C_DOCSTRINGS, ALWAYS_EQ
from test.support.script_helper import assert_python_ok, assert_python_failure
from test import inspect_fodder as mod
from test import inspect_fodder2 as mod2
@ -118,10 +118,6 @@ def gen_coroutine_function_example(self):
yield
return 'spam'
class EqualsToAll:
def __eq__(self, other):
return True
class TestPredicates(IsTestBase):
def test_excluding_predicates(self):
@ -2978,8 +2974,8 @@ class TestSignatureObject(unittest.TestCase):
def foo(a, *, b:int) -> float: pass
self.assertFalse(inspect.signature(foo) == 42)
self.assertTrue(inspect.signature(foo) != 42)
self.assertTrue(inspect.signature(foo) == EqualsToAll())
self.assertFalse(inspect.signature(foo) != EqualsToAll())
self.assertTrue(inspect.signature(foo) == ALWAYS_EQ)
self.assertFalse(inspect.signature(foo) != ALWAYS_EQ)
def bar(a, *, b:int) -> float: pass
self.assertTrue(inspect.signature(foo) == inspect.signature(bar))
@ -3246,8 +3242,8 @@ class TestParameterObject(unittest.TestCase):
self.assertFalse(p != p)
self.assertFalse(p == 42)
self.assertTrue(p != 42)
self.assertTrue(p == EqualsToAll())
self.assertFalse(p != EqualsToAll())
self.assertTrue(p == ALWAYS_EQ)
self.assertFalse(p != ALWAYS_EQ)
self.assertTrue(p == P('foo', default=42,
kind=inspect.Parameter.KEYWORD_ONLY))
@ -3584,8 +3580,8 @@ class TestBoundArguments(unittest.TestCase):
ba = inspect.signature(foo).bind(1)
self.assertTrue(ba == ba)
self.assertFalse(ba != ba)
self.assertTrue(ba == EqualsToAll())
self.assertFalse(ba != EqualsToAll())
self.assertTrue(ba == ALWAYS_EQ)
self.assertFalse(ba != ALWAYS_EQ)
ba2 = inspect.signature(foo).bind(1)
self.assertTrue(ba == ba2)