Skip to content

Instantly share code, notes, and snippets.

@EliahKagan
Created September 21, 2023 23:21
Show Gist options
  • Save EliahKagan/9c49ca00036b3138458cbbfd0c008ebc to your computer and use it in GitHub Desktop.
Save EliahKagan/9c49ca00036b3138458cbbfd0c008ebc to your computer and use it in GitHub Desktop.
(.venv) ek@Glub:~/repos-wsl/GitPython (no-noeffect *=)$ pytest --no-cov test/test_submodule.py
Test session starts (platform: linux, Python 3.12.0, pytest 7.4.2, pytest-sugar 0.9.7)
rootdir: /home/ek/repos-wsl/GitPython
configfile: pyproject.toml
plugins: cov-4.1.0, sugar-0.9.7
collected 26 items
test/test_submodule.py ✓✓✓ 12% █▎
――――――――――――――――――――――――――――――――――――――――――――― TestSubmodule.test_base_bare ―――――――――――――――――――――――――――――――――――――――――――――
self = <test.test_submodule.TestSubmodule testMethod=test_base_bare>
rwrepo = <git.repo.base.Repo '/tmp/bare_test_base_barekm_46_iu'>
@with_rw_repo(k_subm_current, bare=True)
def test_base_bare(self, rwrepo):
> self._do_base_tests(rwrepo)
test/test_submodule.py:470:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <test.test_submodule.TestSubmodule testMethod=test_base_bare>
rwrepo = <git.repo.base.Repo '/tmp/bare_test_base_barekm_46_iu'>
def _do_base_tests(self, rwrepo):
"""Perform all tests in the given repository, it may be bare or nonbare"""
# manual instantiation
smm = Submodule(rwrepo, "\0" * 20)
# name needs to be set in advance
self.assertRaises(AttributeError, getattr, smm, "name")
# iterate - 1 submodule
sms = Submodule.list_items(rwrepo, self.k_subm_current)
assert len(sms) == 1
sm = sms[0]
# at a different time, there is None
assert len(Submodule.list_items(rwrepo, self.k_no_subm_tag)) == 0
assert sm.path == "git/ext/gitdb"
assert sm.path != sm.name # in our case, we have ids there, which don't equal the path
assert sm.url.endswith("github.com/gitpython-developers/gitdb.git")
assert sm.branch_path == "refs/heads/master" # the default ...
assert sm.branch_name == "master"
assert sm.parent_commit == rwrepo.head.commit
# size is always 0
assert sm.size == 0
# the module is not checked-out yet
self.assertRaises(InvalidGitRepositoryError, sm.module)
# which is why we can't get the branch either - it points into the module() repository
self.assertRaises(InvalidGitRepositoryError, getattr, sm, "branch")
# branch_path works, as its just a string
assert isinstance(sm.branch_path, str)
# some commits earlier we still have a submodule, but its at a different commit
smold = next(Submodule.iter_items(rwrepo, self.k_subm_changed))
assert smold.binsha != sm.binsha
assert smold != sm # the name changed
# force it to reread its information
del smold._url
> assert smold.url == sm.url
E AssertionError: assert 'git://gitori...hon/gitdb.git' == 'https://gith...ers/gitdb.git'
E - https://github.com/gitpython-developers/gitdb.git
E + git://gitorious.org/git-python/gitdb.git
test/test_submodule.py:114: AssertionError
test/test_submodule.py ⨯ 15% █▋
―――――――――――――――――――――――――――――――――――――――――――――― TestSubmodule.test_base_rw ――――――――――――――――――――――――――――――――――――――――――――――
self = <test.test_submodule.TestSubmodule testMethod=test_base_rw>
rwrepo = <git.repo.base.Repo '/tmp/non_bare_test_base_rwopiw8uf4/.git'>
@with_rw_repo(k_subm_current)
def test_base_rw(self, rwrepo):
> self._do_base_tests(rwrepo)
test/test_submodule.py:466:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <test.test_submodule.TestSubmodule testMethod=test_base_rw>
rwrepo = <git.repo.base.Repo '/tmp/non_bare_test_base_rwopiw8uf4/.git'>
def _do_base_tests(self, rwrepo):
"""Perform all tests in the given repository, it may be bare or nonbare"""
# manual instantiation
smm = Submodule(rwrepo, "\0" * 20)
# name needs to be set in advance
self.assertRaises(AttributeError, getattr, smm, "name")
# iterate - 1 submodule
sms = Submodule.list_items(rwrepo, self.k_subm_current)
assert len(sms) == 1
sm = sms[0]
# at a different time, there is None
assert len(Submodule.list_items(rwrepo, self.k_no_subm_tag)) == 0
assert sm.path == "git/ext/gitdb"
assert sm.path != sm.name # in our case, we have ids there, which don't equal the path
assert sm.url.endswith("github.com/gitpython-developers/gitdb.git")
assert sm.branch_path == "refs/heads/master" # the default ...
assert sm.branch_name == "master"
assert sm.parent_commit == rwrepo.head.commit
# size is always 0
assert sm.size == 0
# the module is not checked-out yet
self.assertRaises(InvalidGitRepositoryError, sm.module)
# which is why we can't get the branch either - it points into the module() repository
self.assertRaises(InvalidGitRepositoryError, getattr, sm, "branch")
# branch_path works, as its just a string
assert isinstance(sm.branch_path, str)
# some commits earlier we still have a submodule, but its at a different commit
smold = next(Submodule.iter_items(rwrepo, self.k_subm_changed))
assert smold.binsha != sm.binsha
assert smold != sm # the name changed
# force it to reread its information
del smold._url
> assert smold.url == sm.url
E AssertionError: assert 'git://gitori...hon/gitdb.git' == 'https://gith...ers/gitdb.git'
E - https://github.com/gitpython-developers/gitdb.git
E + git://gitorious.org/git-python/gitdb.git
test/test_submodule.py:114: AssertionError
test/test_submodule.py ⨯✓s✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓s✓✓ 100% ██████████
=============================================== short test summary info ================================================
FAILED test/test_submodule.py::TestSubmodule::test_base_bare - AssertionError: assert 'git://gitori...hon/gitdb.git' == 'https://gith...ers/gitdb.git'
FAILED test/test_submodule.py::TestSubmodule::test_base_rw - AssertionError: assert 'git://gitori...hon/gitdb.git' == 'https://gith...ers/gitdb.git'
Results (4.82s):
22 passed
2 failed
- test/test_submodule.py:468 TestSubmodule.test_base_bare
- test/test_submodule.py:464 TestSubmodule.test_base_rw
2 skipped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment