|
7 | 7 | from pymysql._compat import text_type |
8 | 8 | from pymysql.constants import CLIENT |
9 | 9 |
|
| 10 | +import pytest |
| 11 | + |
10 | 12 |
|
11 | 13 | class TempUser: |
12 | 14 | def __init__(self, c, user, db, auth=None, authdata=None, password=None): |
@@ -451,21 +453,23 @@ def test_read_default_group(self): |
451 | 453 | def test_context(self): |
452 | 454 | with self.assertRaises(ValueError): |
453 | 455 | c = self.connect() |
| 456 | + with pytest.warns(DeprecationWarning): |
| 457 | + with c as cur: |
| 458 | + cur.execute('create table test ( a int ) ENGINE=InnoDB') |
| 459 | + c.begin() |
| 460 | + cur.execute('insert into test values ((1))') |
| 461 | + raise ValueError('pseudo abort') |
| 462 | + c = self.connect() |
| 463 | + with pytest.warns(DeprecationWarning): |
454 | 464 | with c as cur: |
455 | | - cur.execute('create table test ( a int ) ENGINE=InnoDB') |
456 | | - c.begin() |
| 465 | + cur.execute('select count(*) from test') |
| 466 | + self.assertEqual(0, cur.fetchone()[0]) |
457 | 467 | cur.execute('insert into test values ((1))') |
458 | | - raise ValueError('pseudo abort') |
459 | | - c.commit() |
460 | | - c = self.connect() |
461 | | - with c as cur: |
462 | | - cur.execute('select count(*) from test') |
463 | | - self.assertEqual(0, cur.fetchone()[0]) |
464 | | - cur.execute('insert into test values ((1))') |
465 | | - with c as cur: |
466 | | - cur.execute('select count(*) from test') |
467 | | - self.assertEqual(1,cur.fetchone()[0]) |
468 | | - cur.execute('drop table test') |
| 468 | + with pytest.warns(DeprecationWarning): |
| 469 | + with c as cur: |
| 470 | + cur.execute('select count(*) from test') |
| 471 | + self.assertEqual(1,cur.fetchone()[0]) |
| 472 | + cur.execute('drop table test') |
469 | 473 |
|
470 | 474 | def test_set_charset(self): |
471 | 475 | c = self.connect() |
|
0 commit comments