<s> from graphitesend import graphitesend <EOL> import unittest2 as unittest <EOL> import socket <EOL> class TestAutoreconnect ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . server = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) <EOL> self . server . setsockopt ( socket . SOL_SOCKET , socket . SO_REUSEADDR , <NUM_LIT:1> ) <EOL> self . server . bind ( ( '<STR_LIT:localhost>' , <NUM_LIT> ) ) <EOL> self . server . listen ( <NUM_LIT:5> ) <EOL> def tearDown ( self ) : <EOL> """<STR_LIT>""" <EOL> graphitesend . reset ( ) <EOL> try : <EOL> self . server . shutdown ( socket . SHUT_RD ) <EOL> self . server . close ( ) <EOL> except Exception : <EOL> pass <EOL> self . server = None <EOL> def test_set_autoreconnect_default ( self ) : <EOL> g = graphitesend . init ( dryrun = True ) <EOL> self . assertEqual ( g . _autoreconnect , False ) <EOL> def test_set_autoreconnect_true ( self ) : <EOL> g = graphitesend . init ( dryrun = True , autoreconnect = True ) <EOL> self . assertEqual ( g . _autoreconnect , True ) <EOL> def test_set_autoreconnect_false ( self ) : <EOL> g = graphitesend . init ( dryrun = True , autoreconnect = False ) <EOL> self . assertEqual ( g . _autoreconnect , False ) <EOL> def test_autoreconnect ( self ) : <EOL> g = graphitesend . GraphiteClient ( autoreconnect = True ) <EOL> g . send ( "<STR_LIT>" , <NUM_LIT> ) <EOL> self . tearDown ( ) <EOL> with self . assertRaises ( graphitesend . GraphiteSendException ) : <EOL> g . send ( "<STR_LIT>" , <NUM_LIT:2> ) <EOL> self . setUp ( ) <EOL> g . send ( "<STR_LIT>" , <NUM_LIT:3> ) </s>
