Add new register_ignores unit tests
Change-Id: Ifd877c18920fb2fe26d34396df8cfa0a9111489f
This commit is contained in:
@@ -22,7 +22,6 @@ _TRUE_VALUES = ('True', 'true', '1', 'yes')
|
||||
|
||||
|
||||
class TestCase(testtools.TestCase):
|
||||
|
||||
"""Test case base class for all unit tests."""
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -20,7 +20,6 @@ Tests for `bashate` module.
|
||||
import mock
|
||||
|
||||
from bashate import bashate
|
||||
|
||||
from bashate.tests import base
|
||||
|
||||
|
||||
@@ -28,29 +27,40 @@ class TestBashate(base.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestBashate, self).setUp()
|
||||
self.run = bashate.BashateRun()
|
||||
|
||||
def test_multi_ignore(self):
|
||||
run = bashate.BashateRun()
|
||||
run.register_ignores('E001|E011')
|
||||
def test_multi_ignore_with_slash(self):
|
||||
self.run.register_ignores('E001|E011')
|
||||
bashate.check_no_trailing_whitespace("if ", self.run)
|
||||
bashate.check_if_then("if ", self.run)
|
||||
|
||||
bashate.check_no_trailing_whitespace("if ", run)
|
||||
bashate.check_if_then("if ", run)
|
||||
self.assertEqual(0, self.run.ERRORS)
|
||||
|
||||
self.assertEqual(run.ERRORS, 0)
|
||||
def test_multi_ignore_with_comma(self):
|
||||
self.run.register_ignores('E001,E011')
|
||||
bashate.check_no_trailing_whitespace("if ", self.run)
|
||||
bashate.check_if_then("if ", self.run)
|
||||
|
||||
self.assertEqual(0, self.run.ERRORS)
|
||||
|
||||
def test_multi_ignore_mixed(self):
|
||||
self.run.register_ignores('E001|E002,E003|E011')
|
||||
bashate.check_no_trailing_whitespace("if ", self.run)
|
||||
bashate.check_if_then("if ", self.run)
|
||||
bashate.check_indents(" echo", self.run)
|
||||
|
||||
self.assertEqual(0, self.run.ERRORS)
|
||||
|
||||
def test_ignore(self):
|
||||
run = bashate.BashateRun()
|
||||
run.register_ignores('E001')
|
||||
self.run.register_ignores('E001')
|
||||
bashate.check_no_trailing_whitespace("if ", self.run)
|
||||
|
||||
bashate.check_no_trailing_whitespace("if ", run)
|
||||
|
||||
self.assertEqual(run.ERRORS, 0)
|
||||
self.assertEqual(0, self.run.ERRORS)
|
||||
|
||||
@mock.patch('bashate.bashate.BashateRun.print_error')
|
||||
def test_while_check_for_do(self, m_print_error):
|
||||
run = bashate.BashateRun()
|
||||
test_line = 'while `do something args`'
|
||||
bashate.check_for_do(test_line, run)
|
||||
bashate.check_for_do(test_line, self.run)
|
||||
|
||||
m_print_error.assert_called_once_with(
|
||||
'E010: Do not on same line as while', test_line)
|
||||
|
||||
Reference in New Issue
Block a user