1
from bzrlib.selftest import TestBase
1
from bzrlib.selftest import TestCase
2
2
from bzrlib.diff import internal_diff
3
3
from cStringIO import StringIO
4
4
def udiff_lines(old, new):
21
21
assert '@@' in lines[2][2:], \
22
22
"Unterminated hunk header for patch:\n%s" % "".join(lines)
24
class AddNL(TestBase):
26
diff generates a valid diff for patches that add a newline
24
class TestDiff(TestCase):
25
def test_add_nl(self):
26
"""diff generates a valid diff for patches that add a newline"""
29
27
lines = udiff_lines(['boo'], ['boo\n'])
31
29
assert lines[4] == '\\ No newline at end of file\n', \
32
30
"expected no-nl, got %r" % lines[4]
35
class AddNL2(TestBase):
37
diff generates a valid diff for patches that change last line and add a
32
def test_add_nl_2(self):
33
"""diff generates a valid diff for patches that change last line and
41
36
lines = udiff_lines(['boo'], ['goo\n'])
43
38
assert lines[4] == '\\ No newline at end of file\n', \
44
39
"expected no-nl, got %r" % lines[4]
46
class RemoveNL(TestBase):
48
diff generates a valid diff for patches that change last line and add a
41
def test_remove_nl(self):
42
"""diff generates a valid diff for patches that change last line and
52
45
lines = udiff_lines(['boo\n'], ['boo'])
54
47
assert lines[5] == '\\ No newline at end of file\n', \
55
48
"expected no-nl, got %r" % lines[5]
50
TEST_CLASSES = [ TestDiff ]