зеркало из https://github.com/github/vitess-gh.git
test: Replace assertTrue(member in collection) constructs with assertIn(member, collection).
assertIn has a nicer error formatting.
This commit is contained in:
Родитель
4ebc1ed16b
Коммит
fe3dde842d
|
@ -16,7 +16,7 @@ class TestCase(unittest.TestCase):
|
|||
cls.env = env
|
||||
|
||||
def assertContains(self, b, a):
|
||||
self.assertTrue(a in b, "%r not found in %r" % (a, b))
|
||||
self.assertIn(a, b)
|
||||
|
||||
class MultiDict(dict):
|
||||
def __getattr__(self, name):
|
||||
|
|
|
@ -114,7 +114,7 @@ class TestStream(framework.TestCase):
|
|||
cu.fetchall()
|
||||
errMsg1 = "error: the query was killed either because it timed out or was canceled: Lost connectioy to MySQL server during query (errno 2013)"
|
||||
errMsg2 = "error: Query execution was interrupted (errno 1317)"
|
||||
self.assertTrue(cm.exception not in (errMsg1, errMsg2), "did not raise interruption error: %s" % str(cm.exception))
|
||||
self.assertNotIn(cm.exception, (errMsg1, errMsg2), "did not raise interruption error: %s" % str(cm.exception))
|
||||
cu.close()
|
||||
except Exception, e:
|
||||
self.fail("Failed with error %s %s" % (str(e), traceback.print_exc()))
|
||||
|
|
|
@ -379,19 +379,19 @@ primary key (name)
|
|||
|
||||
def _check_binlog_server_vars(self, tablet):
|
||||
v = utils.get_vars(tablet.port)
|
||||
self.assertTrue('UpdateStreamKeyRangeStatements' in v)
|
||||
self.assertTrue('UpdateStreamKeyRangeTransactions' in v)
|
||||
self.assertIn('UpdateStreamKeyRangeStatements', v)
|
||||
self.assertIn('UpdateStreamKeyRangeTransactions', v)
|
||||
|
||||
def _check_binlog_player_vars(self, tablet, seconds_behind_master_max = 0):
|
||||
v = utils.get_vars(tablet.port)
|
||||
self.assertTrue('BinlogPlayerMapSize' in v)
|
||||
self.assertTrue('BinlogPlayerSecondsBehindMaster' in v)
|
||||
self.assertTrue('BinlogPlayerSecondsBehindMasterMap' in v)
|
||||
self.assertTrue('BinlogPlayerSourceShardNameMap' in v)
|
||||
self.assertTrue('0' in v['BinlogPlayerSourceShardNameMap'])
|
||||
self.assertIn('BinlogPlayerMapSize', v)
|
||||
self.assertIn('BinlogPlayerSecondsBehindMaster', v)
|
||||
self.assertIn('BinlogPlayerSecondsBehindMasterMap', v)
|
||||
self.assertIn('BinlogPlayerSourceShardNameMap', v)
|
||||
self.assertIn('0', v['BinlogPlayerSourceShardNameMap'])
|
||||
self.assertEquals(v['BinlogPlayerSourceShardNameMap']['0'], 'test_keyspace/80-')
|
||||
self.assertTrue('BinlogPlayerSourceTabletAliasMap' in v)
|
||||
self.assertTrue('0' in v['BinlogPlayerSourceTabletAliasMap'])
|
||||
self.assertIn('BinlogPlayerSourceTabletAliasMap', v)
|
||||
self.assertIn('0', v['BinlogPlayerSourceTabletAliasMap'])
|
||||
if seconds_behind_master_max != 0:
|
||||
self.assertTrue(v['BinlogPlayerSecondsBehindMaster'] <
|
||||
seconds_behind_master_max,
|
||||
|
|
|
@ -210,8 +210,8 @@ class TestUpdateStream(unittest.TestCase):
|
|||
if v['UpdateStreamState'] != 'Enabled':
|
||||
self.fail("Update stream service should be 'Enabled' but is '%s'" %
|
||||
v['UpdateStreamState'])
|
||||
self.assertTrue('DML' in v['UpdateStreamEvents'])
|
||||
self.assertTrue('POS' in v['UpdateStreamEvents'])
|
||||
self.assertIn('DML', v['UpdateStreamEvents'])
|
||||
self.assertIn('POS', v['UpdateStreamEvents'])
|
||||
|
||||
logging.debug('Testing enable -> disable switch starting @ %s',
|
||||
start_position)
|
||||
|
|
|
@ -291,7 +291,7 @@ class TestVTGateFunctions(unittest.TestCase):
|
|||
# Verify keyspace id
|
||||
for result in cursor.results:
|
||||
kid = result[2]
|
||||
self.assertTrue(kid in shard_kid_map[shard_names[shard_index]])
|
||||
self.assertIn(kid, shard_kid_map[shard_names[shard_index]])
|
||||
# Do a cross shard range query and assert all rows are fetched
|
||||
cursor = vtgate_conn.cursor(KEYSPACE_NAME, 'master',
|
||||
keyranges=[get_keyrange('75-95')])
|
||||
|
|
Загрузка…
Ссылка в новой задаче