예제 #1
0
    def test_with_option_dryrun_on_cmdline(self, capsys):
        config = Config(DEFAULT_CONFIG)
        ctx = EchoMockContext(run=Result(), config=config)

        git_clean(ctx, dry_run=True)
        captured = capsys.readouterr()
        expected = "INVOKED: git clean --interactive --dry-run ."
        assert expected in captured.out
예제 #2
0
    def test_with_invoke_option_dry_on_cmdline(self, capsys):
        config = Config(DEFAULT_CONFIG)
        ctx = EchoMockContext(run=Result(), config=config)
        ctx.config.run.dry = True  # CMDLINE-EMULATION

        git_clean(ctx)
        captured = capsys.readouterr()
        expected = "INVOKED: git clean --interactive --dry-run ."
        assert expected in captured.out
예제 #3
0
    def test_with_option_force_on_cmdline(self, capsys):
        config = Config(DEFAULT_CONFIG)
        ctx = EchoMockContext(run=Result(), config=config)
        # ctx.config.git_clean.interactive = False

        git_clean(ctx, force=True)
        captured = capsys.readouterr()
        expected = "INVOKED: git clean --interactive --force ."
        assert expected in captured.out
예제 #4
0
    def test_without_options_if_config_disables_interactive_mode(self, capsys):
        config = Config(DEFAULT_CONFIG)
        ctx = EchoMockContext(run=Result(), config=config)
        ctx.config.git_clean.interactive = False

        git_clean(ctx)
        captured = capsys.readouterr()
        expected = "INVOKED: git clean  ."
        assert expected in captured.out
예제 #5
0
    def test_with_option_dryrun_in_configfile(self, capsys):
        config = Config(DEFAULT_CONFIG)
        ctx = EchoMockContext(run=Result(), config=config)
        # ctx.config.git_clean.interactive = False
        ctx.config.git_clean.dry_run = True

        git_clean(ctx)
        captured = capsys.readouterr()
        expected = "INVOKED: git clean --interactive --dry-run ."
        assert expected in captured.out
예제 #6
0
    def test_dryrun_mode(self, monkeypatch):
        config = Config(DEFAULT_CONFIG)
        ctx = EchoMockContext(config=config)
        ctx.config.run.dry = True

        mock_cleanup_dirs = create_autospec(cleanup_dirs)
        mock_cleanup_files = create_autospec(cleanup_files)
        # mock_invoke_run = create_autospec(EchoMockContext.run)
        monkeypatch.setattr("invoke_cleanup.cleanup_dirs", mock_cleanup_dirs)
        monkeypatch.setattr("invoke_cleanup.cleanup_files", mock_cleanup_files)

        clean_python(ctx)
        mock_cleanup_dirs.assert_called_once_with(EXPECTED_CLEANUP_DIRS,
                                                  dry_run=True,
                                                  **DEFAULT_KWARGS)
        mock_cleanup_files.assert_called_once_with(EXPECTED_CLEANUP_FILES,
                                                   dry_run=True,
                                                   **DEFAULT_KWARGS)