@@ -598,9 +598,9 @@ def test_unix_sockets(self):
598598node .execute ('postgres' ,'select 1' )
599599node .safe_psql ('postgres' ,'select 1' )
600600
601- r = node .replicate ('r' ).start ()
602- r .execute ('postgres' ,'select 1' )
603- r .safe_psql ('postgres' ,'select 1' )
601+ with node .replicate ('r' ).start ()as r :
602+ r .execute ('postgres' ,'select 1' )
603+ r .safe_psql ('postgres' ,'select 1' )
604604
605605def test_auto_name (self ):
606606with get_new_node ().init (allow_streaming = True ).start ()as m :
@@ -617,6 +617,29 @@ def test_auto_name(self):
617617self .assertTrue ('testgres' in m .name )
618618self .assertTrue ('testgres' in r .name )
619619
620+ def test_file_tail (self ):
621+ from testgres .utils import file_tail
622+
623+ s1 = "the quick brown fox jumped over that lazy dog\n "
624+ s2 = "abc\n "
625+ s3 = "def\n "
626+
627+ with tempfile .NamedTemporaryFile (mode = 'r+' ,delete = True )as f :
628+ for i in range (1 ,5000 ):
629+ f .write (s1 )
630+ f .write (s2 )
631+ f .write (s3 )
632+
633+ f .seek (0 )
634+ lines = file_tail (f ,3 )
635+ self .assertEqual (lines [0 ],s1 )
636+ self .assertEqual (lines [1 ],s2 )
637+ self .assertEqual (lines [2 ],s3 )
638+
639+ f .seek (0 )
640+ lines = file_tail (f ,1 )
641+ self .assertEqual (lines [0 ],s3 )
642+
620643def test_isolation_levels (self ):
621644with get_new_node ('node' ).init ().start ()as node :
622645with node .connect ()as con :