<s> import os <EOL> import rethinkdb as r <EOL> from rethinkdb . errors import RqlDriverError <EOL> import unittest <EOL> from remodel . connection import pool , get_conn <EOL> from remodel . helpers import create_tables <EOL> from remodel . models import Model <EOL> from remodel . registry import model_registry , index_registry <EOL> def get_env_settings ( ) : <EOL> settings = { } <EOL> settings [ '<STR_LIT:host>' ] = os . environ . get ( '<STR_LIT>' , None ) <EOL> settings [ '<STR_LIT:port>' ] = os . environ . get ( '<STR_LIT>' , None ) <EOL> settings [ '<STR_LIT>' ] = os . environ . get ( '<STR_LIT>' , None ) <EOL> settings [ '<STR_LIT>' ] = os . environ . get ( '<STR_LIT>' , None ) <EOL> return { k : v for k , v in settings . items ( ) if v is not None } <EOL> pool . configure ( max_connections = <NUM_LIT:1> , ** get_env_settings ( ) ) <EOL> class BaseTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> pass <EOL> def tearDown ( self ) : <EOL> model_registry . clear ( ) <EOL> index_registry . clear ( ) <EOL> class DbBaseTestCase ( BaseTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( DbBaseTestCase , self ) . setUp ( ) <EOL> try : <EOL> with get_conn ( ) as conn : <EOL> r . db_create ( '<STR_LIT>' ) . run ( conn ) <EOL> conn . use ( '<STR_LIT>' ) <EOL> except RqlDriverError : <EOL> raise unittest . SkipTest ( '<STR_LIT>' ) <EOL> def tearDown ( self ) : <EOL> super ( DbBaseTestCase , self ) . tearDown ( ) <EOL> with get_conn ( ) as conn : <EOL> r . db_drop ( '<STR_LIT>' ) . run ( conn ) </s>
