<s> import sys <EOL> import os <EOL> from unittest import TestCase <EOL> from orator . database_manager import DatabaseManager <EOL> from . orm . models import Model , User <EOL> PY2 = sys . version_info [ <NUM_LIT:0> ] == <NUM_LIT:2> <EOL> if PY2 : <EOL> import mock <EOL> else : <EOL> import unittest . mock as mock <EOL> class OratorTestCase ( TestCase ) : <EOL> def tearDown ( self ) : <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> os . remove ( self . local_database ) <EOL> def init_database ( self ) : <EOL> self . local_database = '<STR_LIT>' <EOL> if os . path . exists ( self . local_database ) : <EOL> os . remove ( self . local_database ) <EOL> self . manager = DatabaseManager ( { <EOL> '<STR_LIT:default>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . local_database <EOL> } <EOL> } ) <EOL> with self . manager . transaction ( ) : <EOL> try : <EOL> self . manager . statement ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT:)>' <EOL> ) <EOL> except Exception : <EOL> pass <EOL> Model . set_connection_resolver ( self . manager ) <EOL> self . manager . disconnect ( ) <EOL> def assertRegex ( self , * args , ** kwargs ) : <EOL> if PY2 : <EOL> return self . assertRegexpMatches ( * args , ** kwargs ) <EOL> else : <EOL> return super ( OratorTestCase , self ) . assertRegex ( * args , ** kwargs ) <EOL> def assertNotRegex ( self , * args , ** kwargs ) : <EOL> if PY2 : <EOL> return self . assertNotRegexpMatches ( * args , ** kwargs ) <EOL> else : <EOL> return super ( OratorTestCase , self ) . assertNotRegex ( * args , ** kwargs ) </s>
