File tree Expand file tree Collapse file tree 2 files changed +17
-14
lines changed Expand file tree Collapse file tree 2 files changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -37,18 +37,20 @@ def test_strerror(self):
3737 elif is_osx :
3838 self .assertEqual (os .strerror (40 ), "Message too long" )
3939
40+
4041 def test_open_abplus (self ):
4142 # equivalent to open(self.temp_file, "ab+"), see also test_file.test_open_abplus
4243 fd = os .open (self .temp_file , os .O_APPEND | os .O_CREAT | os .O_RDWR )
4344 try :
4445 f = open (fd , mode = "ab+" , closefd = False )
45- f .write (b"abc" )
46- f .seek (0 )
47- self .assertEqual (f .read (2 ), b"ab" )
48- f .write (b"def" )
49- self .assertEqual (f .read (2 ), b"" )
50- f .seek (0 )
51- self .assertEqual (f .read (6 ), b"abcdef" )
46+ f .raw .write (b"abcxxxx" )
47+ f .raw .seek (0 )
48+ self .assertEqual (f .raw .read (2 ), b"ab" )
49+ f .raw .seek (0 , 2 )
50+ f .raw .write (b"def" )
51+ self .assertEqual (f .raw .read (2 ), b"" )
52+ f .raw .seek (0 )
53+ self .assertEqual (f .raw .read (), b"abcxxxxdef" )
5254 f .close ()
5355 finally :
5456 os .close (fd )
Original file line number Diff line number Diff line change @@ -845,14 +845,15 @@ def test_open_wbplus(self):
845845 f .seek (0 )
846846 self .assertEqual (f .read (), b"abdez" )
847847
848+
848849 def test_open_abplus (self ):
849850 with open (self .temp_file , "ab+" ) as f :
850- f .write (b"abc" )
851- f .seek (0 )
852- self .assertEqual (f .read (2 ), b"ab" )
853- f .write (b"def" )
854- self .assertEqual (f .read (2 ), b"" )
855- f .seek (0 )
856- self .assertEqual (f .read (6 ), b"abcdef" )
851+ f .raw . write (b"abc" )
852+ f .raw . seek (0 )
853+ self .assertEqual (f .raw . read (2 ), b"ab" )
854+ f .raw . write (b"def" )
855+ self .assertEqual (f .raw . read (2 ), b"" )
856+ f .raw . seek (0 )
857+ self .assertEqual (f .raw . read (6 ), b"abcdef" )
857858
858859run_test (__name__ )
You can’t perform that action at this time.
0 commit comments