Best Python code snippet using lemoncheesecake
test_environment.py
Source:test_environment.py
...29 def test_proxy_transaction_rollback(self):30 context = self._fixture(31 {"transaction_per_migration": True, "transactional_ddl": True}32 )33 is_false(self.conn.in_transaction())34 proxy = context.begin_transaction(_per_migration=True)35 is_true(self.conn.in_transaction())36 proxy.rollback()37 is_false(self.conn.in_transaction())38 def test_proxy_transaction_commit(self):39 context = self._fixture(40 {"transaction_per_migration": True, "transactional_ddl": True}41 )42 proxy = context.begin_transaction(_per_migration=True)43 is_true(self.conn.in_transaction())44 proxy.commit()45 is_false(self.conn.in_transaction())46 def test_proxy_transaction_contextmanager_commit(self):47 context = self._fixture(48 {"transaction_per_migration": True, "transactional_ddl": True}49 )50 proxy = context.begin_transaction(_per_migration=True)51 is_true(self.conn.in_transaction())52 with proxy:53 pass54 is_false(self.conn.in_transaction())55 def test_proxy_transaction_contextmanager_rollback(self):56 context = self._fixture(57 {"transaction_per_migration": True, "transactional_ddl": True}58 )59 proxy = context.begin_transaction(_per_migration=True)60 is_true(self.conn.in_transaction())61 def go():62 with proxy:63 raise Exception("hi")64 assert_raises(Exception, go)65 is_false(self.conn.in_transaction())66 def test_proxy_transaction_contextmanager_explicit_rollback(self):67 context = self._fixture(68 {"transaction_per_migration": True, "transactional_ddl": True}69 )70 proxy = context.begin_transaction(_per_migration=True)71 is_true(self.conn.in_transaction())72 with proxy:73 is_true(self.conn.in_transaction())74 proxy.rollback()75 is_false(self.conn.in_transaction())76 is_false(self.conn.in_transaction())77 def test_proxy_transaction_contextmanager_explicit_commit(self):78 context = self._fixture(79 {"transaction_per_migration": True, "transactional_ddl": True}80 )81 proxy = context.begin_transaction(_per_migration=True)82 is_true(self.conn.in_transaction())83 with proxy:84 is_true(self.conn.in_transaction())85 proxy.commit()86 is_false(self.conn.in_transaction())87 is_false(self.conn.in_transaction())88 def test_transaction_per_migration_transactional_ddl(self):89 context = self._fixture(90 {"transaction_per_migration": True, "transactional_ddl": True}91 )92 is_false(self.conn.in_transaction())93 with context.begin_transaction():94 is_false(self.conn.in_transaction())95 with context.begin_transaction(_per_migration=True):96 is_true(self.conn.in_transaction())97 is_false(self.conn.in_transaction())98 is_false(self.conn.in_transaction())99 def test_transaction_per_migration_non_transactional_ddl(self):100 context = self._fixture(101 {"transaction_per_migration": True, "transactional_ddl": False}102 )103 is_false(self.conn.in_transaction())104 with context.begin_transaction():105 is_false(self.conn.in_transaction())106 with context.begin_transaction(_per_migration=True):107 is_true(self.conn.in_transaction())108 is_false(self.conn.in_transaction())109 is_false(self.conn.in_transaction())110 def test_transaction_per_all_transactional_ddl(self):111 context = self._fixture({"transactional_ddl": True})112 is_false(self.conn.in_transaction())113 with context.begin_transaction():114 is_true(self.conn.in_transaction())115 with context.begin_transaction(_per_migration=True):116 is_true(self.conn.in_transaction())117 is_true(self.conn.in_transaction())118 is_false(self.conn.in_transaction())119 def test_transaction_per_all_non_transactional_ddl(self):120 context = self._fixture({"transactional_ddl": False})121 is_false(self.conn.in_transaction())122 with context.begin_transaction():123 is_false(self.conn.in_transaction())124 with context.begin_transaction(_per_migration=True):125 is_true(self.conn.in_transaction())126 is_false(self.conn.in_transaction())127 is_false(self.conn.in_transaction())128 def test_transaction_per_all_sqlmode(self):129 context = self._fixture({"as_sql": True})130 context.execute("step 1")131 with context.begin_transaction():132 context.execute("step 2")133 with context.begin_transaction(_per_migration=True):134 context.execute("step 3")135 context.execute("step 4")136 context.execute("step 5")137 if context.impl.transactional_ddl:138 self._assert_impl_steps(139 "step 1",140 "BEGIN",141 "step 2",142 "step 3",143 "step 4",144 "COMMIT",145 "step 5",146 )147 else:148 self._assert_impl_steps(149 "step 1", "step 2", "step 3", "step 4", "step 5"150 )151 def test_transaction_per_migration_sqlmode(self):152 context = self._fixture(153 {"as_sql": True, "transaction_per_migration": True}154 )155 context.execute("step 1")156 with context.begin_transaction():157 context.execute("step 2")158 with context.begin_transaction(_per_migration=True):159 context.execute("step 3")160 context.execute("step 4")161 context.execute("step 5")162 if context.impl.transactional_ddl:163 self._assert_impl_steps(164 "step 1",165 "step 2",166 "BEGIN",167 "step 3",168 "COMMIT",169 "step 4",170 "step 5",171 )172 else:173 self._assert_impl_steps(174 "step 1", "step 2", "step 3", "step 4", "step 5"175 )176 @config.requirements.autocommit_isolation177 def test_autocommit_block(self):178 context = self._fixture({"transaction_per_migration": True})179 is_false(self.conn.in_transaction())180 with context.begin_transaction():181 is_false(self.conn.in_transaction())182 with context.begin_transaction(_per_migration=True):183 is_true(self.conn.in_transaction())184 with context.autocommit_block():185 is_false(self.conn.in_transaction())186 is_true(self.conn.in_transaction())187 is_false(self.conn.in_transaction())188 is_false(self.conn.in_transaction())189 @config.requirements.autocommit_isolation190 def test_autocommit_block_no_transaction(self):191 context = self._fixture({"transaction_per_migration": True})192 is_false(self.conn.in_transaction())193 with context.autocommit_block():194 is_false(self.conn.in_transaction())195 is_false(self.conn.in_transaction())196 def test_autocommit_block_transactional_ddl_sqlmode(self):197 context = self._fixture(198 {199 "transaction_per_migration": True,200 "transactional_ddl": True,201 "as_sql": True,202 }203 )204 with context.begin_transaction():205 context.execute("step 1")206 with context.begin_transaction(_per_migration=True):207 context.execute("step 2")208 with context.autocommit_block():209 context.execute("step 3")...
test_utils.py
Source:test_utils.py
...31 self.a.c.y == self.b.c.y32 )33 is_true(l1.compare(l1))34 is_true(l1.compare(l2))35 is_false(l1.compare(l3))36 def test_compare_clauselist_not_associative(self):37 l1 = ClauseList(38 self.a.c.x, self.a.c.y, self.b.c.y, operator=operators.sub)39 l2 = ClauseList(40 self.b.c.y, self.a.c.x, self.a.c.y, operator=operators.sub)41 is_true(l1.compare(l1))42 is_false(l1.compare(l2))43 def test_compare_clauselist_assoc_different_operator(self):44 l1 = and_(45 self.a.c.x == self.b.c.y,46 self.a.c.y == self.b.c.z47 )48 l2 = or_(49 self.a.c.y == self.b.c.z,50 self.a.c.x == self.b.c.y,51 )52 is_false(l1.compare(l2))53 def test_compare_clauselist_not_assoc_different_operator(self):54 l1 = ClauseList(55 self.a.c.x, self.a.c.y, self.b.c.y, operator=operators.sub)56 l2 = ClauseList(57 self.a.c.x, self.a.c.y, self.b.c.y, operator=operators.div)58 is_false(l1.compare(l2))59 def test_compare_binds(self):60 b1 = bindparam("foo", type_=Integer())61 b2 = bindparam("foo", type_=Integer())62 b3 = bindparam("bar", type_=Integer())63 b4 = bindparam("foo", type_=String())64 def c1(): return 565 def c2(): return 666 b5 = bindparam("foo", type_=Integer(), callable_=c1)67 b6 = bindparam("foo", type_=Integer(), callable_=c2)68 b7 = bindparam("foo", type_=Integer(), callable_=c1)69 b8 = bindparam("foo", type_=Integer, value=5)70 b9 = bindparam("foo", type_=Integer, value=6)71 is_false(b1.compare(b5))72 is_true(b5.compare(b7))73 is_false(b5.compare(b6))74 is_true(b1.compare(b2))75 # currently not comparing "key", as we often have to compare76 # anonymous names. however we should really check for that77 is_true(b1.compare(b3))78 is_false(b1.compare(b4))79 is_false(b1.compare(b8))80 is_false(b8.compare(b9))81 is_true(b8.compare(b8))82class MiscTest(fixtures.TestBase):83 def test_column_element_no_visit(self):84 class MyElement(ColumnElement):85 pass86 eq_(87 sql_util.find_tables(MyElement(), check_columns=True),88 []...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!