/opt/cloudlinux/venv/lib/python3.11/site-packages/psycopg2/tests
NameSizeModeActions
__pycache__/-0755rm
dbapi20.py322860644editdlrm
dbapi20_tpc.py41430644editdlrm
testconfig.py12490644editdlrm
testutils.py111330644editdlrm
test_async.py157290644editdlrm
test_bugX000.py16780644editdlrm
test_bug_gc.py17190644editdlrm
test_cancel.py37050644editdlrm
test_connection.py395950644editdlrm
test_copy.py118640644editdlrm
test_cursor.py213260644editdlrm
test_dates.py240590644editdlrm
test_errcodes.py21070644editdlrm
test_extras_dictcursor.py174040644editdlrm
test_green.py41980644editdlrm
test_lobject.py152620644editdlrm
test_module.py111230644editdlrm
test_notify.py71370644editdlrm
test_psycopg2_dbapi20.py19320644editdlrm
test_quote.py82520644editdlrm
test_transaction.py92140644editdlrm
test_types_basic.py186230644editdlrm
test_types_extras.py625780644editdlrm
test_with.py73650644editdlrm
__init__.py29660644editdlrm
Edit: /opt/cloudlinux/venv/lib/python3.11/site-packages/psycopg2/tests/dbapi20_tpc.py (4143B)
""" Python DB API 2.0 driver Two Phase Commit compliance test suite. """ import unittest class TwoPhaseCommitTests(unittest.TestCase): driver = None def connect(self): """Make a database connection.""" raise NotImplementedError _last_id = 0 _global_id_prefix = "dbapi20_tpc:" def make_xid(self, con): id = TwoPhaseCommitTests._last_id TwoPhaseCommitTests._last_id += 1 return con.xid(42, "%s%d" % (self._global_id_prefix, id), "qualifier") def test_xid(self): con = self.connect() try: xid = con.xid(42, "global", "bqual") except self.driver.NotSupportedError: self.fail("Driver does not support transaction IDs.") self.assertEquals(xid[0], 42) self.assertEquals(xid[1], "global") self.assertEquals(xid[2], "bqual") # Try some extremes for the transaction ID: xid = con.xid(0, "", "") self.assertEquals(tuple(xid), (0, "", "")) xid = con.xid(0x7fffffff, "a" * 64, "b" * 64) self.assertEquals(tuple(xid), (0x7fffffff, "a" * 64, "b" * 64)) def test_tpc_begin(self): con = self.connect() try: xid = self.make_xid(con) try: con.tpc_begin(xid) except self.driver.NotSupportedError: self.fail("Driver does not support tpc_begin()") finally: con.close() def test_tpc_commit_without_prepare(self): con = self.connect() try: xid = self.make_xid(con) con.tpc_begin(xid) cursor = con.cursor() cursor.execute("SELECT 1") con.tpc_commit() finally: con.close() def test_tpc_rollback_without_prepare(self): con = self.connect() try: xid = self.make_xid(con) con.tpc_begin(xid) cursor = con.cursor() cursor.execute("SELECT 1") con.tpc_rollback() finally: con.close() def test_tpc_commit_with_prepare(self): con = self.connect() try: xid = self.make_xid(con) con.tpc_begin(xid) cursor = con.cursor() cursor.execute("SELECT 1") con.tpc_prepare() con.tpc_commit() finally: con.close() def test_tpc_rollback_with_prepare(self): con = self.connect() try: xid = self.make_xid(con) con.tpc_begin(xid) cursor = con.cursor() cursor.execute("SELECT 1") con.tpc_prepare() con.tpc_rollback() finally: con.close() def test_tpc_begin_in_transaction_fails(self): con = self.connect() try: xid = self.make_xid(con) cursor = con.cursor() cursor.execute("SELECT 1") self.assertRaises(self.driver.ProgrammingError, con.tpc_begin, xid) finally: con.close() def test_tpc_begin_in_tpc_transaction_fails(self): con = self.connect() try: xid = self.make_xid(con) cursor = con.cursor() cursor.execute("SELECT 1") self.assertRaises(self.driver.ProgrammingError, con.tpc_begin, xid) finally: con.close() def test_commit_in_tpc_fails(self): # calling commit() within a TPC transaction fails with # ProgrammingError. con = self.connect() try: xid = self.make_xid(con) con.tpc_begin(xid) self.assertRaises(self.driver.ProgrammingError, con.commit) finally: con.close() def test_rollback_in_tpc_fails(self): # calling rollback() within a TPC transaction fails with # ProgrammingError. con = self.connect() try: xid = self.make_xid(con) con.tpc_begin(xid) self.assertRaises(self.driver.ProgrammingError, con.rollback) finally: con.close()