Source code for sqlobject.tests.test_mysql

importpytest
fromsqlobjectimport SQLObject, IntCol
fromsqlobject.sqlbuilderimport Select, ANY
fromsqlobject.tests.dbtestimport getConnection, setupClass
try:
 connection = getConnection()
except (AttributeError, NameError):
 # The module was imported during documentation building
 pass
else:
 if connection.dbName != "mysql":
 pytestmark = pytest.mark.skip("These tests require MySQL")
[docs] classSOTestSOListMySQL(SQLObject): pass
[docs] deftest_list_databases(): assert connection.db in connection.listDatabases()
[docs] deftest_list_tables(): setupClass(SOTestSOListMySQL) assert SOTestSOListMySQL.sqlmeta.table in connection.listTables()
[docs] classSOTestANY(SQLObject): value = IntCol()
[docs] deftest_ANY(): setupClass(SOTestANY) SOTestANY(value=10) SOTestANY(value=20) SOTestANY(value=30) assert len(list(SOTestANY.select( SOTestANY.q.value > ANY(Select([SOTestANY.q.value]))))) == 2
[docs] classSOTestMySQLidSize(SQLObject): classsqlmeta: idSize = 'BIG'
[docs] deftest_idSize(): assert 'id BIGINT PRIMARY KEY AUTO_INCREMENT' \ in SOTestMySQLidSize.createTableSQL(connection=connection)[0]