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