Example #1
0
    def test_ensure_when_content_without_line_feed(self):
        with NamedTemporaryFile('w') as f:
            f.write('hi')
            f.flush()

            ensure_line_in_file(f.name, 'hello')

            with open(f.name, 'r') as r:
                self.assertEqual('hi\nhello\n', r.read())
Example #2
0
    def test_ensure_when_content_without_line_feed(self):
        with NamedTemporaryFile("w") as f:
            f.write("hi")
            f.flush()

            ensure_line_in_file(f.name, "hello")

            with open(f.name, "r") as r:
                self.assertEqual("hi\nhello\n", r.read())
Example #3
0
 def test_ensure_when_empty(self):
     with NamedTemporaryFile('r') as f:
         ensure_line_in_file(f.name, 'hello')
         self.assertEqual(f.read(), 'hello\n')
Example #4
0
 def test_ensure_auto_line_feed(self):
     with NamedTemporaryFile('r') as f:
         ensure_line_in_file(f.name, 'hello\n')
         self.assertEqual('hello\n', f.read())
Example #5
0
 def test_ensure_when_empty(self):
     with NamedTemporaryFile("r") as f:
         ensure_line_in_file(f.name, "hello")
         self.assertEqual(f.read(), "hello\n")
Example #6
0
 def test_ensure_auto_line_feed(self):
     with NamedTemporaryFile("r") as f:
         ensure_line_in_file(f.name, "hello\n")
         self.assertEqual("hello\n", f.read())