-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot execute tests if git is not installed #101
Comments
Good call,
[https://github.com/peritus/bumpversion/blob/5d1749ad7fd76cb8a166de8cf7774b30e9cbe217/tests/test_cli.py#L30-L33] should probably be something along the lines of
(same for mercurial perhaps) Sorry, never tried executing the tests on windows without git installed. Want to submit a pull request ? |
In fact, this is not a Windows problem. For example, when mercurial is not installed, you have the same problem. I think the right way to check if a VCS tool is installed is as follow: def is_installed(cmd):
"""
Check that a command is installed and its help message can be displayed.
This function works well for "git", "hg" and "svn" if their ``bin`` path
are in the PATH environment variable.
:param cmd: Name of the command.
:return: True if the command is installed, otherwise False.
"""
try:
args = [cmd, "help"]
if hasattr(subprocess, "DEVNULL"):
# Py3 has DEVNULL
return subprocess.check_call(args,
stdout=subprocess.DEVNULL,
env=SUBPROCESS_ENV) or True
else:
from os import devnull
with open(devnull, b"wb") as DEVNULL:
return subprocess.check_call(args,
stdout=DEVNULL,
env=SUBPROCESS_ENV) or True
except EnvironmentError:
# command not found
return False Then, you can rewrite the xfail_if_no_* functions: xfail_if_no_git = pytest.mark.xfail(
not is_installed("git"),
reason="git is not installed"
)
xfail_if_no_hg = pytest.mark.xfail(
not is_installed("hg"),
reason="hg is not installed"
) Regards, |
This seems like an awful lot of code just to figure out whether git/hg is installed or not, I'm quite hesitant to merge it just because of that. Nevertheless, the test suite should work whether or not git is installed. |
Windows 7, bumpversion 0.5.3
There is no git command on my machine so test.py falls immediately.
Let's consider change tests.py so developer can skip tests required git and execute another ones.
The text was updated successfully, but these errors were encountered: