Fixed several assertTrue() that were intended to be assertEqual(). (GH-8191)
Fixed also testing the "always" warning filter.
This commit is contained in:
parent
c287545d62
commit
b796e7dcdc
|
@ -24,7 +24,7 @@ class BasicWrapTestCase(unittest.TestCase):
|
||||||
f.argtypes = [c_byte, c_wchar, c_int, c_long, c_float, c_double]
|
f.argtypes = [c_byte, c_wchar, c_int, c_long, c_float, c_double]
|
||||||
result = f(self.wrap(1), self.wrap("x"), self.wrap(3), self.wrap(4), self.wrap(5.0), self.wrap(6.0))
|
result = f(self.wrap(1), self.wrap("x"), self.wrap(3), self.wrap(4), self.wrap(5.0), self.wrap(6.0))
|
||||||
self.assertEqual(result, 139)
|
self.assertEqual(result, 139)
|
||||||
self.assertTrue(type(result), int)
|
self.assertIs(type(result), int)
|
||||||
|
|
||||||
def test_pointers(self):
|
def test_pointers(self):
|
||||||
f = dll._testfunc_p_p
|
f = dll._testfunc_p_p
|
||||||
|
|
|
@ -138,7 +138,7 @@ class TestPkg(unittest.TestCase):
|
||||||
|
|
||||||
s = """
|
s = """
|
||||||
from t2 import *
|
from t2 import *
|
||||||
self.assertTrue(dir(), ['self', 'sub'])
|
self.assertEqual(dir(), ['self', 'sub'])
|
||||||
"""
|
"""
|
||||||
self.run_code(s)
|
self.run_code(s)
|
||||||
|
|
||||||
|
|
|
@ -5843,7 +5843,7 @@ class LinuxKernelCryptoAPI(unittest.TestCase):
|
||||||
op=socket.ALG_OP_ENCRYPT, iv=iv)
|
op=socket.ALG_OP_ENCRYPT, iv=iv)
|
||||||
enc = op.recv(msglen * multiplier)
|
enc = op.recv(msglen * multiplier)
|
||||||
self.assertEqual(len(enc), msglen * multiplier)
|
self.assertEqual(len(enc), msglen * multiplier)
|
||||||
self.assertTrue(enc[:msglen], ciphertext)
|
self.assertEqual(enc[:msglen], ciphertext)
|
||||||
|
|
||||||
op, _ = algo.accept()
|
op, _ = algo.accept()
|
||||||
with op:
|
with op:
|
||||||
|
|
|
@ -264,7 +264,7 @@ class TestSupport(unittest.TestCase):
|
||||||
with support.temp_cwd(name=TESTFN):
|
with support.temp_cwd(name=TESTFN):
|
||||||
self.assertEqual(os.path.basename(os.getcwd()), TESTFN)
|
self.assertEqual(os.path.basename(os.getcwd()), TESTFN)
|
||||||
self.assertFalse(os.path.exists(TESTFN))
|
self.assertFalse(os.path.exists(TESTFN))
|
||||||
self.assertTrue(os.path.basename(os.getcwd()), here)
|
self.assertEqual(os.getcwd(), here)
|
||||||
|
|
||||||
|
|
||||||
def test_temp_cwd__name_none(self):
|
def test_temp_cwd__name_none(self):
|
||||||
|
|
|
@ -1360,7 +1360,7 @@ class TestTokenize(TestCase):
|
||||||
tokenize_module.detect_encoding = orig_detect_encoding
|
tokenize_module.detect_encoding = orig_detect_encoding
|
||||||
tokenize_module._tokenize = orig__tokenize
|
tokenize_module._tokenize = orig__tokenize
|
||||||
|
|
||||||
self.assertTrue(encoding_used, encoding)
|
self.assertEqual(encoding_used, encoding)
|
||||||
|
|
||||||
def test_oneline_defs(self):
|
def test_oneline_defs(self):
|
||||||
buf = []
|
buf = []
|
||||||
|
|
|
@ -148,10 +148,14 @@ class FilterTests(BaseTest):
|
||||||
self.module.resetwarnings()
|
self.module.resetwarnings()
|
||||||
self.module.filterwarnings("always", category=UserWarning)
|
self.module.filterwarnings("always", category=UserWarning)
|
||||||
message = "FilterTests.test_always"
|
message = "FilterTests.test_always"
|
||||||
self.module.warn(message, UserWarning)
|
def f():
|
||||||
self.assertTrue(message, w[-1].message)
|
self.module.warn(message, UserWarning)
|
||||||
self.module.warn(message, UserWarning)
|
f()
|
||||||
self.assertTrue(w[-1].message, message)
|
self.assertEqual(len(w), 1)
|
||||||
|
self.assertEqual(w[-1].message.args[0], message)
|
||||||
|
f()
|
||||||
|
self.assertEqual(len(w), 2)
|
||||||
|
self.assertEqual(w[-1].message.args[0], message)
|
||||||
|
|
||||||
def test_always_after_default(self):
|
def test_always_after_default(self):
|
||||||
with original_warnings.catch_warnings(record=True,
|
with original_warnings.catch_warnings(record=True,
|
||||||
|
|
Loading…
Reference in New Issue