GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — TestGit.test_refresh changes Git.GIT_PYTHON_GIT_EXECUTABLE for other tests · Issue #1811 · gitpython-developers/GitPython

TestGit.test_refresh changes Git.GIT_PYTHON_GIT_EXECUTABLE for other tests #1811

New issue
Copy link
New issue
Copy link
Closed
#1812
Closed
TestGit.test_refresh changes Git.GIT_PYTHON_GIT_EXECUTABLE for other tests#1811
#1812
Copy link
Labels
acknowledgedhelp wanted

Description

@EliahKagan
EliahKagan
opened on Jan 25, 2024
Issue body actions

In test_git.py, TestGit.test_refresh tests the behavior of git.refresh when called with bad (nonexistent) and good (existing and usable) explicit path arguments.

  • With the bad path, there could only be a lasting change to Git.GIT_PYTHON_GIT_EXECUTABLE or other global state due to a bug in git.refresh, or in git.cmd.Git.refresh or some other code git.refresh uses.
  • But with the good path, it remains set as Git.GIT_PYTHON_GIT_EXECUTABLE, and tests that run after test_refresh use that instead of the original value that (when tests are run normally in an environment that supports them) is usually "git".

GitPython/test/test_git.py

Lines 309 to 316 in 307f198

def test_refresh(self):
# Test a bad git path refresh.
self.assertRaises(GitCommandNotFound, refresh, "yada")
# Test a good path refresh.
which_cmd = "where" if os.name == "nt" else "command -v"
path = os.popen("{0} git".format(which_cmd)).read().strip().split("\n")[0]
refresh(path)

>>> from git import Git
>>> from test.test_git import TestGit
>>> t = TestGit()
>>> Git.GIT_PYTHON_GIT_EXECUTABLE
'git'
>>> t.test_refresh()
>>> Git.GIT_PYTHON_GIT_EXECUTABLE
'C:\\Users\\ek\\scoop\\shims\\git.exe'

(That was run on Windows, but the effect is not specific to Windows.)

Although the good-path code can be simplified in the way it finds the absolute path it tests, that is not the cause of this.

In the absence of bugs in the code under test, this change to Git.GIT_PYTHON_GIT_EXECUTABLE between some tests and others should make no difference on most working test systems, because both the old and new paths should both work and typically run the same git installation. However, if there are bugs related to this attribute that the test suite should reveal or that otherwise interact with tests, then I think this may lead to inaccurate or less useful results, or complicate troubleshooting.

Reacted by Sebastian Thiel

Activity

  1. EliahKagan
    added 2 commits that reference this issue on Jan 25, 2024

    Start work on making refresh tests restore state

    5ad7cb2

    Re-refresh to restore state after refresh tests

    b3fc30e
  2. Byron
    added
    acknowledged
    help wanted
    on Jan 26, 2024
  3. Byron
    closed this as completedin #1812on Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgedhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.