Skip to content
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

Add test actually using git #347

Open
takluyver opened this issue May 22, 2020 · 0 comments · May be fixed by #445
Open

Add test actually using git #347

takluyver opened this issue May 22, 2020 · 0 comments · May be fixed by #445

Comments

@takluyver
Copy link
Member

#345 concerned an issue where git wasn't producing output quite as we expected. There are several tests in test_build.py and test_sdist.py which mock out the git command so they run independently of the system state. But it would be good to have an integration test which sets up a real git repository in a temporary directory, which we could add cases like #345 to.

This should cleanly skip itself if the git command is not available.

mawillcockson added a commit to mawillcockson/flit that referenced this issue Sep 29, 2021
git is isolated using the following environment, which are set globally
for the duration of that the new pytest fixture "tmp_git" is used:

GIT_CONFIG_GLOBAL
GIT_CONFIG_NOSYSTEM
HOME
GIT_AUTHOR_EMAIL
GIT_AUTHOR_NAME
GIT_AUTHOR_DATE
GIT_COMMITTER_EMAIL
GIT_COMMITTER_NAME
GIT_COMMITTER_DATE

GIT_DIR and GIT_WORK_TREE could be set so that git can be called using
any method, but instead a git() function is added that uses git's -C
command-line option.

These were taken from one of git's test scripts:
https://github.com/git/git/blob/cefe983a320c03d7843ac78e73bd513a27806845/t/test-lib.sh#L454-L461

There are probably other ways git can be isolated.

The repository is initialized with an empty commit, but this isn't
strictly necessary, it just makes some of the possible tests require
less setup.

The new tmp_project fixture copies the sample module from
./test/samples/module1_toml to the project and commits the files.

A test is added for pypa#345 as an example of how this can be used.

A pytest marker is added so that tests with either "needgit" or
"needsgit" in the name are skipped if python can't find an executable
named "git".

The tox configuration is changed and another pytest marker is added so
that those tests can be run by themselves:

tox -- -m needgit

or skipped:

tox -- -m "not needgit"

Type hints were added to help with development, but aren't necessary to
keep.
@takluyver takluyver linked a pull request Sep 29, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant