Esempio n. 1
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")
Esempio n. 2
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)
Esempio n. 3
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])
Esempio n. 4
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")
Esempio n. 5
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)
Esempio n. 6
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])
Esempio n. 7
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)
Esempio n. 8
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])
Esempio n. 9
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")
Esempio n. 10
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)
Esempio n. 11
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)
Esempio n. 12
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")
Esempio n. 13
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)
Esempio n. 14
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])