Ejemplo n.º 1
0
 def test_readline_and_append_line(self):
     """read_lines: returns items as passed to append_line"""
     filename = self.tmpdir+'/outfile'
     items = ["one", "two", "five"]
     for i in items:
         append_line(filename, i)
     self.assertEqual(items, read_lines(filename))
Ejemplo n.º 2
0
 def test_readline_and_append_line(self):
     """read_lines: returns items as passed to append_line"""
     filename = self.tmpdir + '/outfile'
     items = ["one", "two", "five"]
     for i in items:
         append_line(filename, i)
     self.assertEqual(items, read_lines(filename))
Ejemplo n.º 3
0
 def test_append(self):
     """append_line: adds a line to the end of an existing file"""
     oldlines = ["line one", "line two", "and I'm line three"]
     outfile = self.tmpdir+'/outfile'
     with open(outfile, 'w') as outf:
         for line in oldlines:
             outf.write(line+'\n')
     line = "this line contains a newline already\n"
     append_line(outfile, line)
     self.assertEqual(open(outfile).read(), '\n'.join(oldlines+[line]))
Ejemplo n.º 4
0
 def test_append(self):
     """append_line: adds a line to the end of an existing file"""
     oldlines = ["line one", "line two", "and I'm line three"]
     outfile = self.tmpdir + '/outfile'
     with open(outfile, 'w') as outf:
         for line in oldlines:
             outf.write(line + '\n')
     line = "this line contains a newline already\n"
     append_line(outfile, line)
     self.assertEqual(open(outfile).read(), '\n'.join(oldlines + [line]))
Ejemplo n.º 5
0
 def test_empty(self):
     """append_line: create file + append \\n when needed"""
     line = "this is a line of text with no newline"
     outfile = self.tmpdir+'/outfile'
     append_line(outfile, line)
     self.assertEqual(open(outfile).read(), line+'\n')
Ejemplo n.º 6
0
 def test_empty(self):
     """append_line: create file + append \\n when needed"""
     line = "this is a line of text with no newline"
     outfile = self.tmpdir + '/outfile'
     append_line(outfile, line)
     self.assertEqual(open(outfile).read(), line + '\n')