本文整理汇总了Python中testutils.ConnectingTestCase.setUp方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectingTestCase.setUp方法的具体用法?Python ConnectingTestCase.setUp怎么用?Python ConnectingTestCase.setUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testutils.ConnectingTestCase
的用法示例。
在下文中一共展示了ConnectingTestCase.setUp方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from testutils import ConnectingTestCase [as 别名]
# 或者: from testutils.ConnectingTestCase import setUp [as 别名]
def setUp(self):
ConnectingTestCase.setUp(self)
self.curs = self.conn.cursor()
self.DATE = psycopg2.extensions.PYDATE
self.TIME = psycopg2.extensions.PYTIME
self.DATETIME = psycopg2.extensions.PYDATETIME
self.INTERVAL = psycopg2.extensions.PYINTERVAL
示例2: setUp
# 需要导入模块: from testutils import ConnectingTestCase [as 别名]
# 或者: from testutils.ConnectingTestCase import setUp [as 别名]
def setUp(self):
ConnectingTestCase.setUp(self)
cur = self.conn.cursor()
cur.execute('''
CREATE TEMPORARY TABLE table1 (
id int PRIMARY KEY
)''')
self.conn.commit()
示例3: setUp
# 需要导入模块: from testutils import ConnectingTestCase [as 别名]
# 或者: from testutils.ConnectingTestCase import setUp [as 别名]
def setUp(self):
ConnectingTestCase.setUp(self)
curs = self.conn.cursor()
try:
curs.execute("delete from test_with")
self.conn.commit()
except psycopg2.ProgrammingError:
# assume table doesn't exist
self.conn.rollback()
curs.execute("create table test_with (id integer primary key)")
self.conn.commit()
示例4: setUp
# 需要导入模块: from testutils import ConnectingTestCase [as 别名]
# 或者: from testutils.ConnectingTestCase import setUp [as 别名]
def setUp(self):
ConnectingTestCase.setUp(self)
self.sync_conn = self.conn
self.conn = self.connect(async=True)
self.wait(self.conn)
curs = self.conn.cursor()
curs.execute('''
CREATE TEMPORARY TABLE table1 (
id int PRIMARY KEY
)''')
self.wait(curs)
示例5: setUp
# 需要导入模块: from testutils import ConnectingTestCase [as 别名]
# 或者: from testutils.ConnectingTestCase import setUp [as 别名]
def setUp(self):
ConnectingTestCase.setUp(self)
from psycopg2.extras import NamedTupleConnection
try:
from collections import namedtuple
except ImportError:
return
self.conn = self.connect(connection_factory=NamedTupleConnection)
curs = self.conn.cursor()
curs.execute("CREATE TEMPORARY TABLE nttest (i int, s text)")
curs.execute("INSERT INTO nttest VALUES (1, 'foo')")
curs.execute("INSERT INTO nttest VALUES (2, 'bar')")
curs.execute("INSERT INTO nttest VALUES (3, 'baz')")
self.conn.commit()
示例6: setUp
# 需要导入模块: from testutils import ConnectingTestCase [as 别名]
# 或者: from testutils.ConnectingTestCase import setUp [as 别名]
def setUp(self):
ConnectingTestCase.setUp(self)
self.conn.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE)
curs = self.conn.cursor()
curs.execute('''
CREATE TEMPORARY TABLE table1 (
id int PRIMARY KEY
)''')
# The constraint is set to deferrable for the commit_failed test
curs.execute('''
CREATE TEMPORARY TABLE table2 (
id int PRIMARY KEY,
table1_id int,
CONSTRAINT table2__table1_id__fk
FOREIGN KEY (table1_id) REFERENCES table1(id) DEFERRABLE)''')
curs.execute('INSERT INTO table1 VALUES (1)')
curs.execute('INSERT INTO table2 VALUES (1, 1)')
self.conn.commit()
示例7: setUp
# 需要导入模块: from testutils import ConnectingTestCase [as 别名]
# 或者: from testutils.ConnectingTestCase import setUp [as 别名]
def setUp(self):
ConnectingTestCase.setUp(self)
self._create_temp_table()
示例8: setUp
# 需要导入模块: from testutils import ConnectingTestCase [as 别名]
# 或者: from testutils.ConnectingTestCase import setUp [as 别名]
def setUp(self):
ConnectingTestCase.setUp(self)
self.lo_oid = None
self.tmpdir = None
示例9: setUp
# 需要导入模块: from testutils import ConnectingTestCase [as 别名]
# 或者: from testutils.ConnectingTestCase import setUp [as 别名]
def setUp(self):
self._cb = psycopg2.extensions.get_wait_callback()
psycopg2.extensions.set_wait_callback(self.crappy_callback)
ConnectingTestCase.setUp(self)
self.to_error = None