diff options
author | Evan Martin <martine@danga.com> | 2011-07-27 16:59:22 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-07-27 17:03:16 (GMT) |
commit | ba3f2a416cab345bf357abc979a77fe80d7058fe (patch) | |
tree | 5c3f7a0e33d29fc719e3795a139fdf4ad9d52699 /misc/ninja_test.py | |
parent | f60aee4330413b4d8ccf36b4d12bbe2f8fdd2913 (diff) | |
download | Ninja-ba3f2a416cab345bf357abc979a77fe80d7058fe.zip Ninja-ba3f2a416cab345bf357abc979a77fe80d7058fe.tar.gz Ninja-ba3f2a416cab345bf357abc979a77fe80d7058fe.tar.bz2 |
ninja.py: fix the new test and pass the test
From a patch from Elazar Leibovich <elazarl@gmail.com>.
Diffstat (limited to 'misc/ninja_test.py')
-rwxr-xr-x | misc/ninja_test.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/misc/ninja_test.py b/misc/ninja_test.py index 555f189..44c6230 100755 --- a/misc/ninja_test.py +++ b/misc/ninja_test.py @@ -20,26 +20,33 @@ from StringIO import StringIO import ninja LONGWORD = 'a' * 10 +INDENT = ' ' class TestLineWordWrap(unittest.TestCase): def setUp(self): self.out = StringIO() - self.n = ninja.Writer(self.out, width=5) + self.n = ninja.Writer(self.out, width=8) def test_single_long_word(self): # We shouldn't wrap a single long word. self.n._line(LONGWORD) - self.assertEqual(LONGWORD, self.out.getvalue()) + self.assertEqual(LONGWORD + '\n', self.out.getvalue()) def test_few_long_words(self): # We should wrap a line where the second word is overlong. self.n._line(' '.join(['x', LONGWORD, 'y'])) - self.assertEqual('x \n' + LONGWORD + '\ny', self.out.getvalue()) - - def test_few_long_words_space(self): - # We should also wrap indented lines. - self.n._line(' '.join(['x', LONGWORD, 'y']), indent=2) - self.assertEqual('x \n ' + LONGWORD + '\n y', self.out.getvalue()) + self.assertEqual(' $\n'.join(['x', + INDENT + LONGWORD, + INDENT + 'y']) + '\n', + self.out.getvalue()) + + def test_few_long_words_indented(self): + # Check wrapping in the presence of indenting. + self.n._line(' '.join(['x', LONGWORD, 'y']), indent=1) + self.assertEqual(' $\n'.join([' ' + 'x', + ' ' + INDENT + LONGWORD, + ' ' + INDENT + 'y']) + '\n', + self.out.getvalue()) if __name__ == '__main__': unittest.main() |