@@ -598,9 +598,9 @@ def test_unix_sockets(self):
598
598
node .execute ('postgres' , 'select 1' )
599
599
node .safe_psql ('postgres' , 'select 1' )
600
600
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' )
604
604
605
605
def test_auto_name (self ):
606
606
with get_new_node ().init (allow_streaming = True ).start () as m :
@@ -617,6 +617,29 @@ def test_auto_name(self):
617
617
self .assertTrue ('testgres' in m .name )
618
618
self .assertTrue ('testgres' in r .name )
619
619
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
+
620
643
def test_isolation_levels (self ):
621
644
with get_new_node ('node' ).init ().start () as node :
622
645
with node .connect () as con :
0 commit comments