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())
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())
def test_ensure_when_empty(self): with NamedTemporaryFile('r') as f: ensure_line_in_file(f.name, 'hello') self.assertEqual(f.read(), 'hello\n')
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())
def test_ensure_when_empty(self): with NamedTemporaryFile("r") as f: ensure_line_in_file(f.name, "hello") self.assertEqual(f.read(), "hello\n")
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())