File tree Expand file tree Collapse file tree 2 files changed +0
-35
lines changed
Expand file tree Collapse file tree 2 files changed +0
-35
lines changed Original file line number Diff line number Diff line change @@ -490,20 +490,6 @@ def cursor(self, cursor=None):
490490 return cursor (self )
491491 return self .cursorclass (self )
492492
493- def __enter__ (self ):
494- """Context manager that returns a Cursor"""
495- warnings .warn (
496- "Context manager API of Connection object is deprecated; Use conn.begin()" ,
497- DeprecationWarning )
498- return self .cursor ()
499-
500- def __exit__ (self , exc , value , traceback ):
501- """On successful exit, commit. On exception, rollback"""
502- if exc :
503- self .rollback ()
504- else :
505- self .commit ()
506-
507493 # The following methods are INTERNAL USE ONLY (called from Cursor)
508494 def query (self , sql , unbuffered = False ):
509495 # if DEBUG:
Original file line number Diff line number Diff line change @@ -450,27 +450,6 @@ def test_read_default_group(self):
450450 )
451451 self .assertTrue (conn .open )
452452
453- def test_context (self ):
454- with self .assertRaises (ValueError ):
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 ):
464- with c as cur :
465- cur .execute ('select count(*) from test' )
466- self .assertEqual (0 , cur .fetchone ()[0 ])
467- cur .execute ('insert into test values ((1))' )
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' )
473-
474453 def test_set_charset (self ):
475454 c = self .connect ()
476455 c .set_charset ('utf8mb4' )
You can’t perform that action at this time.
0 commit comments