def test_set_character_set(self): cmy1 = MySQL(buffered=True) self.assertRaises(MySQLInterfaceError, cmy1.set_character_set, 'latin2') cmy1.connect(**self.connect_kwargs) orig = cmy1.character_set_name() cmy1.set_character_set('utf8') charset = cmy1.character_set_name() self.assertNotEqual(orig, charset) self.assertEqual('utf8', charset) self.assertRaises(MySQLInterfaceError, cmy1.set_character_set, 'ham_spam') variables = ('character_set_connection', ) exp = { b'character_set_connection': b'utf8', } self.assertEqual(exp, get_variables(cmy1, variables=variables)) exp = { b'character_set_connection': b'big5', } cmy1.set_character_set('big5') self.assertEqual(exp, get_variables(cmy1, variables=variables))
def test_character_set_name(self): cmy1 = MySQL(buffered=True) self.assertRaises(MySQLInterfaceError, cmy1.character_set_name) cmy1.connect(**self.connect_kwargs) self.assertEqual('latin1', cmy1.character_set_name())
def test_set_character_set(self): cmy1 = MySQL(buffered=True) self.assertRaises(MySQLInterfaceError, cmy1.set_character_set, 'latin2') cmy1.connect(**self.connect_kwargs) orig = cmy1.character_set_name() cmy1.set_character_set('utf8') charset = cmy1.character_set_name() self.assertNotEqual(orig, charset) self.assertEqual('utf8', charset) self.assertRaises(MySQLInterfaceError, cmy1.set_character_set, 'ham_spam') variables = ('character_set_connection',) exp = {b'character_set_connection': b'utf8',} self.assertEqual(exp, get_variables(cmy1, variables=variables)) exp = {b'character_set_connection': b'big5',} cmy1.set_character_set('big5') self.assertEqual(exp, get_variables(cmy1, variables=variables))
def test___init__(self): cmy = MySQL() self.assertEqual(False, cmy.buffered()) self.assertEqual(False, cmy.raw()) cmy = MySQL(buffered=True, raw=True) self.assertEqual(True, cmy.buffered()) self.assertEqual(True, cmy.raw()) exp = 'gbk' cmy = MySQL(charset_name=exp) cmy.connect(**self.connect_kwargs) self.assertEqual(exp, cmy.character_set_name())