diff --git a/bashate/bashate.py b/bashate/bashate.py index 43821df..23a6704 100644 --- a/bashate/bashate.py +++ b/bashate/bashate.py @@ -264,7 +264,7 @@ def main(): parser.add_argument('-s', '--show', action='store_true', default=False) opts = parser.parse_args() - if opts.show is True: + if opts.show: messages.print_messages() sys.exit(0) diff --git a/bashate/tests/test_bashate.py b/bashate/tests/test_bashate.py index b5d7e49..3ba1ba4 100644 --- a/bashate/tests/test_bashate.py +++ b/bashate/tests/test_bashate.py @@ -33,34 +33,20 @@ class TestBashate(base.TestCase): super(TestBashate, self).setUp() self.run = bashate.BashateRun() - @mock.patch('argparse.ArgumentParser') @mock.patch('bashate.bashate.BashateRun') - def test_main_no_files(self, m_bashaterun, m_argparser): - m_opts = mock.MagicMock() - m_opts.files = [] - m_parser_obj = mock.MagicMock() - m_parser_obj.parse_args = mock.Mock(return_value=m_opts) - m_argparser.return_value = m_parser_obj - + @mock.patch('sys.argv') + def test_main_no_files(self, m_bashaterun, m_argv): m_run_obj = mock.MagicMock() m_run_obj.ERRORS = 0 m_bashaterun.return_value = m_run_obj result = bashate.main() - - m_parser_obj.print_usage.assert_called_once_with() expected_return = 1 self.assertEqual(expected_return, result) - @mock.patch('argparse.ArgumentParser') @mock.patch('bashate.bashate.BashateRun') - def test_main_return_one_on_errors(self, m_bashaterun, m_argparser): - m_opts = mock.MagicMock() - m_opts.files = 'not_a_file' - m_parser_obj = mock.MagicMock() - m_parser_obj.parse_args = mock.Mock(return_value=m_opts) - m_argparser.return_value = m_parser_obj - + @mock.patch('sys.argv') + def test_main_return_one_on_errors(self, m_bashaterun, m_argv): m_run_obj = mock.MagicMock() m_run_obj.WARNINGS = 1 m_run_obj.ERRORS = 1 @@ -70,15 +56,9 @@ class TestBashate(base.TestCase): expected_return = 1 self.assertEqual(expected_return, result) - @mock.patch('argparse.ArgumentParser') @mock.patch('bashate.bashate.BashateRun') - def test_main_return_one_on_ioerror(self, m_bashaterun, m_argparser): - m_opts = mock.MagicMock() - m_opts.files = 'not_a_file' - m_parser_obj = mock.MagicMock() - m_parser_obj.parse_args = mock.Mock(return_value=m_opts) - m_argparser.return_value = m_parser_obj - + @mock.patch('sys.argv') + def test_main_return_one_on_ioerror(self, m_bashaterun, m_argv): m_run_obj = mock.MagicMock() m_run_obj.ERRORS = 0 m_run_obj.check_files = mock.Mock(side_effect=IOError)