Beispiel #1
0
def test_bundle_gitignores_command_not_found_oserror(patch):
    """
    Test what happens when executing the git command failed.
    """
    patch.object(subprocess, 'run', side_effect=OSError())
    result = Bundle.gitignores()
    assert result == []
Beispiel #2
0
def test_bundle_gitignores_command_not_found(patch):
    """
    Test what happens when there's no git command available.
    """
    patch.object(subprocess, 'run', side_effect=FileNotFoundError())
    result = Bundle.gitignores()
    assert result == []
Beispiel #3
0
def test_bundle_gitignores_failed(patch):
    """
    Test what happens when the gitignore command fails
    """
    patch.object(subprocess, 'run')
    subprocess.run().returncode = 1
    result = Bundle.gitignores()
    subprocess.run().stdout.split.assert_not_called()
    assert result == []
Beispiel #4
0
def test_bundle_gitignores(patch):
    """
    Ensures gitignores uses can produce the list of ignored files.
    """
    patch.object(delegator, 'run')
    result = Bundle.gitignores()
    command = 'git ls-files --others --ignored --exclude-standard'
    delegator.run.assert_called_with(command)
    delegator.run().out.split.assert_called_with('\n')
    assert result == delegator.run().out.split()
Beispiel #5
0
def test_bundle_gitignores(patch):
    """
    Ensures gitignores uses can produce the list of ignored files.
    """
    patch.object(subprocess, 'run')
    subprocess.run().returncode = 0
    result = Bundle.gitignores()
    command = ['git', 'ls-files', '--others', '--ignored',
               '--exclude-standard']
    subprocess.run.assert_called_with(command, encoding='utf8',
                                      stderr=subprocess.DEVNULL,
                                      stdout=subprocess.PIPE)
    subprocess.run().stdout.split.assert_called_with('\n')
    assert result == subprocess.run().stdout.split()
Beispiel #6
0
def test_bundle_gitignores(patch):
    """
    Ensures gitignores uses can produce the list of ignored files.
    """
    patch.object(subprocess, "run")
    subprocess.run().returncode = 0
    result = Bundle.gitignores()
    command = [
        "git",
        "ls-files",
        "--others",
        "--ignored",
        "--exclude-standard",
    ]
    subprocess.run.assert_called_with(
        command,
        encoding="utf8",
        stderr=subprocess.DEVNULL,
        stdout=subprocess.PIPE,
    )
    subprocess.run().stdout.split.assert_called_with("\n")
    assert result == subprocess.run().stdout.split()