Beispiel #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")
Beispiel #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)
Beispiel #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])
Beispiel #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")
Beispiel #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)
Beispiel #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])
Beispiel #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)
Beispiel #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])
Beispiel #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")
Beispiel #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)
Beispiel #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)
Beispiel #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")
Beispiel #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)
Beispiel #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])