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