~afrantzis/bzr-text-checker/empty-line-at-eof

« back to all changes in this revision

Viewing changes to tests/__init__.py

  • Committer: Marius Kruger
  • Date: 2009-05-04 22:10:53 UTC
  • Revision ID: amanic@gmail.com-20090504221053-5a2mcgv0isnpymhl
Always store line numbers as 1-based like editors show it, 
and don't increment it when displaying.
Fixup the bad tests that where wrong.

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
        out,err = self.run_bzr('commit -m x', retcode=3,
106
106
            error_regexes=["""\
107
107
bzr: ERROR: New trailing white space was found in the following files:
108
 
    a.py: 2, 3
 
108
    a.py: 1, 2
109
109
 
110
110
The following source files doesn't have a newline at the end:
111
111
    a.py
117
117
        self.assertEqual(out, '')
118
118
        self.assertContainsRe(err, """\
119
119
New trailing white space was found in the following files:
120
 
    a.py: 2, 3""")
 
120
    a.py: 1, 2""")
121
121
 
122
122
        #self.run_bzr('uncommit --force') # reset the stage
123
123
        write_file(self.working_tree, 'NEWS', '\tfoo \nbar\t')
126
126
        self.assertEqual(out, '')
127
127
        self.assertContainsRe(err, """\
128
128
New trailing white space was found in the following files:
129
 
    NEWS: 2, 3
 
129
    NEWS: 1, 2
130
130
 
131
131
The following source files doesn't have a newline at the end:
132
132
    NEWS""")
250
250
        self.textChecker._warn_or_fail()
251
251
        self.assertEndsWith(self._get_log(keep_log_file=True), """\
252
252
New trailing white space was found in the following files:
253
 
    a.py: 2
 
253
    a.py: 1
254
254
""")
255
255
 
256
256
    def test_fail(self):
261
261
            self.textChecker._warn_or_fail)
262
262
        self.assertEqual(str(e), """\
263
263
New trailing white space was found in the following files:
264
 
    a.py: 2
 
264
    a.py: 1
265
265
The commit was rejected because of failed text checks,
266
266
you can force it by using the --text-check-warn-only option""")
267
267
 
273
273
        self.assertEndsWith(self._get_log(keep_log_file=True), """\
274
274
Tab characters were found in the following files.
275
275
They should either be replaced by "\\t" or by spaces:
276
 
    a.py: 2
 
276
    a.py: 1
277
277
""")
278
278
 
279
279
    def test_warn_long_lines(self):
283
283
        self.textChecker._warn_or_fail()
284
284
        self.assertEndsWith(self._get_log(keep_log_file=True), """\
285
285
New long lines was found in the following files:
286
 
    a.py: 2
 
286
    a.py: 1
287
287
""")