示例#1
0
    def test_main_version(self, mock_parse_args, mock_exit, mock_print):
        mock_exit.side_effect = SystemExit
        mock_parse_args.return_value = mock.MagicMock(
            verbose=1,
            version=True,
        )

        with self.assertRaises(SystemExit):
            main()

        mock_parse_args.assert_called_once_with()
        mock_exit.assert_called_once_with(0)
        mock_print.assert_called_once_with(mock.ANY)
示例#2
0
    def test_main_version(self, mock_parse_args, mock_exit, mock_print):
        mock_exit.side_effect = SystemExit
        mock_parse_args.return_value = mock.MagicMock(
            verbose=1,
            version=True,
        )

        with self.assertRaises(SystemExit):
            main()

        mock_parse_args.assert_called_once_with()
        mock_exit.assert_called_once_with(0)
        mock_print.assert_called_once_with(mock.ANY)
示例#3
0
    def test_main_without_config(self, mock_parse_args, mock_get_logger,
                                 mock_run):
        args = mock.MagicMock(
            verbose=1,
            version=False,
            path=[os.path.join('path', '..')],
            config=None,
        )
        mock_parse_args.return_value = args

        main()

        mock_parse_args.assert_called_once_with()
        mock_get_logger.assert_called_once_with('')
        mock_get_logger().setLevel.assert_called_once_with(logging.INFO)
        mock_run.assert_called_once_with(os.getcwd(), PEP8_CONFIG, args)
示例#4
0
def test_ci() -> None:
    assert (main(
        RuntimeConfig(
            config_path=str(TEST_DATA / "subconfig" / IMPORTANIZE_INI_CONFIG),
            path_names=[str(TEST_DATA / "input.py")],
            is_ci_mode=True,
            is_subconfig_allowed=False,
        )) == 1)
示例#5
0
    def test_main_without_config(self,
                                 mock_parse_args,
                                 mock_get_logger,
                                 mock_run):
        args = mock.MagicMock(
            verbose=1,
            version=False,
            path=[os.path.join('path', '..')],
            config=None,
        )
        mock_parse_args.return_value = args

        main()

        mock_parse_args.assert_called_once_with()
        mock_get_logger.assert_called_once_with('')
        mock_get_logger().setLevel.assert_called_once_with(logging.INFO)
        mock_run.assert_called_once_with(os.getcwd(), PEP8_CONFIG, args)
示例#6
0
    def test_main_with_config(self, mock_parse_args, mock_get_logger,
                              mock_loads, mock_run, mock_read):
        args = mock.MagicMock(
            verbose=1,
            version=False,
            path=[os.path.join('path', '..')],
            config=mock.sentinel.config,
        )
        mock_parse_args.return_value = args

        main()

        mock_parse_args.assert_called_once_with()
        mock_get_logger.assert_called_once_with('')
        mock_get_logger().setLevel.assert_called_once_with(logging.INFO)
        mock_read.assert_called_once_with(mock.sentinel.config)
        mock_loads.assert_called_once_with(mock_read.return_value)
        mock_run.assert_called_once_with(os.getcwd(), mock_loads.return_value,
                                         args)
示例#7
0
    def test_main_with_config(self,
                              mock_parse_args,
                              mock_get_logger,
                              mock_loads,
                              mock_run,
                              mock_read):
        args = mock.MagicMock(
            verbose=1,
            version=False,
            path=['/path/../'],
            config=mock.sentinel.config,
        )
        mock_parse_args.return_value = args

        main()

        mock_parse_args.assert_called_once_with()
        mock_get_logger.assert_called_once_with('')
        mock_get_logger().setLevel.assert_called_once_with(logging.INFO)
        mock_read.assert_called_once_with(mock.sentinel.config)
        mock_loads.assert_called_once_with(mock_read.return_value)
        mock_run.assert_called_once_with('/', mock_loads.return_value, args)