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

Tests assume that the git default branch is "master" #10350

Closed
1 task done
pfmoore opened this issue Aug 12, 2021 · 10 comments
Closed
1 task done

Tests assume that the git default branch is "master" #10350

pfmoore opened this issue Aug 12, 2021 · 10 comments
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior

Comments

@pfmoore
Copy link
Member

pfmoore commented Aug 12, 2021

Description

My git config has "main" as the default branch (I don't know where this got set TBH)

❯ git config --get init.defaultbranch 
main

The following tests are failing:

FAILED tests/functional/test_install_vcs_git.py::test_git_install_branch_again_after_branch_changes - AssertionError: Script returned code: 1
FAILED tests/functional/test_install_vcs_git.py::test_install_git_branch_not_cached - AssertionError: Script returned code: 1
FAILED tests/functional/test_install_vcs_git.py::test_editable__no_revision - AssertionError: assert 'main' == 'master'

FAILED tests/functional/test_vcs_git.py::test_get_current_branch - AssertionError: assert 'main' == 'master'
FAILED tests/functional/test_vcs_git.py::test_resolve_commit_not_on_branch - AssertionError: Script returned code: 1

Expected behavior

Tests should not depend on the user's git configuration

pip version

Latest checkout from git, main branch (ironically :-))

Python version

3.9.4

OS

Windows 10

How to Reproduce

  1. Configure git to default to the "main" branch
  2. Then run the pip test suite
  3. The above errors occur

Output

No response

Code of Conduct

@pfmoore pfmoore added type: bug A confirmed bug or unintended behavior S: needs triage Issues/PRs that need to be triaged labels Aug 12, 2021
@pfmoore
Copy link
Member Author

pfmoore commented Aug 12, 2021

I'm not sure how best to fix this, logging it as an issue so it doesn't get forgotten. I'm not sure if I'll have time to fix it myself, I can simply ignore these errors on my local machine for now.

@uranusjr
Copy link
Member

Hmm, I can’t reproduce (at least your first one).

$ git config --add init.defaultbranch main  # This sets the config.
$ git config --get init.defaultbranch
main
$ tox -e py38 -- -k test_git_install_branch_again_after_branch_changes
[a ton of output]
===================== 1 passed, 2242 deselected, 116 warnings in 41.94s =====================
__________________________________________ summary __________________________________________
  py38: commands succeeded
  congratulations :)

There’s probably some Git magic we’re not getting right…

@pradyunsg
Copy link
Member

pradyunsg commented Aug 12, 2021

I've had this set for a while, and the tests certainly work.

Did you set init.defaultbranch globally or just locally on a single repository (likely pip's)?

The output of the following will help confirm/eliminate this hypothesis:

git config --list --global
git config --list --local

@pfmoore
Copy link
Member Author

pfmoore commented Aug 12, 2021

It's set globally. Don't worry too much about it - if it's only happening for me, I'll try to work out what's odd with my config first. As I said, I can ignore those test failures for now.

@AbhinavOmprakash
Copy link

has something like this happened before? the tests fail on a local machine but pass during CI? I am experiencing something similar.
for e.g.

FAILED tests/functional/test_vcs_git.py::test_partial_clone - TypeError: CreateProcess() argument 8 must be str or None, not WindowsPath
FAILED tests/functional/test_vcs_git.py::test_partial_clone_without_server_support - TypeError: CreateProcess() argument 8 must be str or None,...
FAILED tests/functional/test_vcs_git.py::test_clone_without_partial_clone_support - TypeError: CreateProcess() argument 8 must be str or None....

maybe we could think about using docker for development if these issues occur more than a few times?

@pradyunsg
Copy link
Member

maybe we could think about using docker for development if these issues occur more than a few times?

Very much not. pip runs on a variety of platforms. Pushing all of our development to docker would means everything else is a second class citizen, and I don't think we want that. I'd much rather we identify the issues of why these tests fail in some environments and fix that.

@AbhinavOmprakash
Copy link

okay, fair enough. makes sense

@ichard26
Copy link
Member

@pfmoore have you ran into this issue again since opening this issue? It's been a while since I last tried to reproduce this, but I wasn't successful like the others as well. It's perplexing as AFAIU, the test harness does try to isolate git's configuration from the user's environment.

@ichard26
Copy link
Member

ichard26 commented Nov 1, 2024

Unless it turns out that @pfmoore is still running into this, I'm going to say this is no longer a concern. We haven't been able to reproduce the issue and things haven't broke broadly so yeah. LFTM.

@ichard26 ichard26 closed this as completed Nov 1, 2024
@pfmoore
Copy link
Member Author

pfmoore commented Nov 1, 2024

Sorry I missed the previous question, no it's not been happening for a while, so agreed, it can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

5 participants