<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import mock <EOL> import pytest <EOL> import rethinkdb as r <EOL> import util . db_control as dbc <EOL> class TestDB ( object ) : <EOL> @ classmethod <EOL> def teardown_class ( cls ) : <EOL> dbc . start ( ) <EOL> def setup ( self ) : <EOL> dbc . stop ( ) <EOL> def test_alive ( self ) : <EOL> assert not dbc . alive ( ) <EOL> dbc . start ( ) <EOL> assert dbc . alive ( ) <EOL> def test_start ( self ) : <EOL> assert not dbc . alive ( ) <EOL> dbc . start ( ) <EOL> try : <EOL> r . connect ( ) <EOL> except r . errors . ReqlDriverError : <EOL> assert False <EOL> @ mock . patch ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_start_timeout ( self , mock_conn ) : <EOL> assert not dbc . alive ( ) <EOL> mock_conn . side_effect = r . errors . ReqlDriverError ( '<STR_LIT>' ) <EOL> with pytest . raises ( dbc . DBTimeout ) : <EOL> dbc . start ( ) <EOL> def test_stop ( self ) : <EOL> assert not dbc . alive ( ) <EOL> dbc . start ( ) <EOL> dbc . stop ( ) <EOL> try : <EOL> r . connect ( ) <EOL> assert False <EOL> except r . errors . ReqlDriverError : <EOL> assert True <EOL> @ mock . patch ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> def test_stop_raises ( self ) : <EOL> assert not dbc . alive ( ) <EOL> dbc . start ( ) <EOL> with mock . patch ( '<STR_LIT>' ) as mock_log : <EOL> mock_log . return_value = '<STR_LIT>' <EOL> with pytest . raises ( dbc . DBTimeout ) : <EOL> dbc . stop ( ) <EOL> def test_restart ( self ) : <EOL> assert not dbc . alive ( ) <EOL> dbc . start ( ) <EOL> dbc . restart ( ) <EOL> try : <EOL> r . connect ( ) <EOL> except r . errors . ReqlDriverError : <EOL> assert False </s>
