Beispiel #1
0
 def test_writeLinesOverBytes(self):
     """Test writing limited by lines, not bytes"""
     hf = Head(self.outfile,"w",bytes=500,lines=1)
     hf.write(self.intext)
     txt = self.outfile.getvalue()
     self.assertEquals(txt.count("\n"),1)
     self.assertEquals(txt,self.intext.split("\n")[0]+"\n")
Beispiel #2
0
 def test_writeLinesOverBytes(self):
     """Test writing limited by lines, not bytes"""
     hf = Head(self.outfile, "w", bytes=500, lines=1)
     hf.write(self.intext)
     txt = self.outfile.getvalue()
     self.assertEquals(txt.count("\n"), 1)
     self.assertEquals(txt, self.intext.split("\n")[0] + "\n")
Beispiel #3
0
 def test_WriteBytesOverLines(self):
     """Test writing limited by bytes, not lines"""
     hf = Head(self.outfile,"w",bytes=5,lines=2)
     hf.write(self.intext)
     txt = self.outfile.getvalue()
     self.assertEquals(len(txt),5)
     self.assertEquals(txt,self.intext[:5])
Beispiel #4
0
 def test_WriteBytesOverLines(self):
     """Test writing limited by bytes, not lines"""
     hf = Head(self.outfile, "w", bytes=5, lines=2)
     hf.write(self.intext)
     txt = self.outfile.getvalue()
     self.assertEquals(len(txt), 5)
     self.assertEquals(txt, self.intext[:5])
Beispiel #5
0
 def test_WriteHeadLines(self):
     """Test writing lines to head of file."""
     hf = Head(self.outfile, "w", lines=2)
     hf.write(self.intext)
     self.assertEquals(self.outfile.getvalue().count("\n"), 2)
     self.assertEquals(self.outfile.getvalue(),
                       "\n".join(self.intext.split("\n")[:2]) + "\n")
Beispiel #6
0
 def test_ReadLinesOverBytes(self):
     """Test reading limited by lines, not bytes"""
     hf = Head(self.infile, "r", bytes=500, lines=1)
     txt = hf.read()
     self.assertEquals(txt.count("\n"), 1)
     self.assertEquals(txt, self.intext.split("\n")[0] + "\n")
Beispiel #7
0
 def test_ReadBytesOverLines(self):
     """Test reading limited by bytes, not lines"""
     hf = Head(self.infile, "r", bytes=5, lines=2)
     txt = hf.read()
     self.assertEquals(len(txt), 5)
     self.assertEquals(txt, self.intext[:5])
Beispiel #8
0
 def test_ReadHeadLongLines(self):
     """Test reading all lines from head of file."""
     hf = Head(self.infile, "r", lines=200)
     txt = hf.read()
     self.assertEquals(txt, self.intext)
Beispiel #9
0
 def test_ReadHeadLinesExact(self):
     """Test reading exact number of lines from head of file."""
     hf = Head(self.infile, "r", lines=3)
     txt = hf.read()
     self.assertEquals(txt.count("\n"), 2)
     self.assertEquals(txt, self.intext)
Beispiel #10
0
 def test_ReadHeadLines(self):
     """Test reading lines from head of file."""
     hf = Head(self.infile, "r", lines=2)
     txt = hf.read()
     self.assertEquals(txt.count("\n"), 2)
     self.assertEquals(txt, "\n".join(self.intext.split("\n")[:2]) + "\n")
Beispiel #11
0
 def test_ReadHeadLongBytes(self):
     """Test reading entirety of head of file."""
     hf = Head(self.infile, "r", bytes=1000)
     txt = hf.read()
     self.assertEquals(txt, self.intext)
Beispiel #12
0
 def test_ReadHeadLinesExact(self):
     """Test reading exact number of lines from head of file."""
     hf = Head(self.infile,"r",lines=3)
     txt = hf.read()
     self.assertEquals(txt.count("\n"),2)
     self.assertEquals(txt,self.intext)
Beispiel #13
0
 def test_WriteHeadBytes(self):
     """Test writing bytes to head of a file."""
     hf = Head(self.outfile, "w", bytes=10)
     hf.write(self.intext)
     self.assertEquals(len(self.outfile.getvalue()), 10)
     self.assertEquals(self.outfile.getvalue(), self.intext[:10])
Beispiel #14
0
 def test_WriteHeadLines(self):
     """Test writing lines to head of file."""
     hf = Head(self.outfile,"w",lines=2)
     hf.write(self.intext)
     self.assertEquals(self.outfile.getvalue().count("\n"),2)
     self.assertEquals(self.outfile.getvalue(),"\n".join(self.intext.split("\n")[:2])+"\n")
Beispiel #15
0
 def test_WriteHeadLongLines(self):
     """Test writing all lines to head of file."""
     hf = Head(self.outfile,"w",lines=200)
     hf.write(self.intext)
     self.assertEquals(self.outfile.getvalue(),self.intext)
Beispiel #16
0
 def test_WriteHeadLongBytes(self):
     """Test writing entirety of head of file."""
     hf = Head(self.outfile,"w",bytes=1000)
     hf.write(self.intext)
     self.assertEquals(self.outfile.getvalue(),self.intext)
Beispiel #17
0
 def test_WriteHeadBytes(self):
     """Test writing bytes to head of a file."""
     hf = Head(self.outfile,"w",bytes=10)
     hf.write(self.intext)
     self.assertEquals(len(self.outfile.getvalue()),10)
     self.assertEquals(self.outfile.getvalue(),self.intext[:10])
Beispiel #18
0
 def test_ReadLinesOverBytes(self):
     """Test reading limited by lines, not bytes"""
     hf = Head(self.infile,"r",bytes=500,lines=1)
     txt = hf.read()
     self.assertEquals(txt.count("\n"),1)
     self.assertEquals(txt,self.intext.split("\n")[0]+"\n")
Beispiel #19
0
 def test_ReadBytesOverLines(self):
     """Test reading limited by bytes, not lines"""
     hf = Head(self.infile,"r",bytes=5,lines=2)
     txt = hf.read()
     self.assertEquals(len(txt),5)
     self.assertEquals(txt,self.intext[:5])
Beispiel #20
0
 def test_ReadHeadLongLines(self):
     """Test reading all lines from head of file."""
     hf = Head(self.infile,"r",lines=200)
     txt = hf.read()
     self.assertEquals(txt,self.intext)
Beispiel #21
0
 def test_WriteHeadLongBytes(self):
     """Test writing entirety of head of file."""
     hf = Head(self.outfile, "w", bytes=1000)
     hf.write(self.intext)
     self.assertEquals(self.outfile.getvalue(), self.intext)
Beispiel #22
0
 def test_ReadHeadLongBytes(self):
     """Test reading entirety of head of file."""
     hf = Head(self.infile,"r",bytes=1000)
     txt = hf.read()
     self.assertEquals(txt,self.intext)
Beispiel #23
0
 def test_WriteHeadLongLines(self):
     """Test writing all lines to head of file."""
     hf = Head(self.outfile, "w", lines=200)
     hf.write(self.intext)
     self.assertEquals(self.outfile.getvalue(), self.intext)
Beispiel #24
0
 def test_ReadHeadLines(self):
     """Test reading lines from head of file."""
     hf = Head(self.infile,"r",lines=2)
     txt = hf.read()
     self.assertEquals(txt.count("\n"),2)
     self.assertEquals(txt,"\n".join(self.intext.split("\n")[:2])+"\n")
Beispiel #25
0
 def test_ReadHeadBytes(self):
     """Test reading bytes from head of a file."""
     hf = Head(self.infile, "r", bytes=10)
     txt = hf.read()
     self.assertEquals(len(txt), 10)
     self.assertEquals(txt, self.intext[:10])
Beispiel #26
0
 def test_ReadHeadBytes(self):
     """Test reading bytes from head of a file."""
     hf = Head(self.infile,"r",bytes=10)
     txt = hf.read()
     self.assertEquals(len(txt),10)
     self.assertEquals(txt,self.intext[:10])