Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf6c3262

Browse files
authored
Redesign new decorator to better separate concerns
_allow_file_protocol was effectively a _patch_git_config fixture,being no no shorter, simpler, or clearer by hard-coding thespecific name and value to patch. So this changes it to be that.As a secondary issue, it previously was called with no arguments,then that would be used as a decorator. That was unintutive and itwas easy to omit the parentheses accidentally. This resolves that.
1 parent4f594cd commitf6c3262

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎test/test_submodule.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333

3434

3535
@contextlib.contextmanager
36-
def_allow_file_protocol():
37-
"""Temporarilyset protocol.file.allow to always, using environment variables."""
36+
def_patch_git_config(name,value):
37+
"""Temporarilyadd a git config name-value pair, using environment variables."""
3838
pair_index=int(os.getenv("GIT_CONFIG_COUNT","0"))
3939

4040
# This is recomputed each time the context is entered, for compatibility with
4141
# existing GIT_CONFIG_* environment variables, even if changed in this process.
4242
patcher=mock.patch.dict(os.environ, {
4343
"GIT_CONFIG_COUNT":str(pair_index+1),
44-
f"GIT_CONFIG_KEY_{pair_index}":"protocol.file.allow",
45-
f"GIT_CONFIG_VALUE_{pair_index}":"always",
44+
f"GIT_CONFIG_KEY_{pair_index}":name,
45+
f"GIT_CONFIG_VALUE_{pair_index}":value,
4646
})
4747

4848
withpatcher:
@@ -727,7 +727,7 @@ def test_add_empty_repo(self, rwdir):
727727
# end for each checkout mode
728728

729729
@with_rw_directory
730-
@_allow_file_protocol()
730+
@_patch_git_config("protocol.file.allow","always")
731731
deftest_list_only_valid_submodules(self,rwdir):
732732
repo_path=osp.join(rwdir,"parent")
733733
repo=git.Repo.init(repo_path)
@@ -756,7 +756,7 @@ def test_list_only_valid_submodules(self, rwdir):
756756
""",
757757
)
758758
@with_rw_directory
759-
@_allow_file_protocol()
759+
@_patch_git_config("protocol.file.allow","always")
760760
deftest_git_submodules_and_add_sm_with_new_commit(self,rwdir):
761761
parent=git.Repo.init(osp.join(rwdir,"parent"))
762762
parent.git.submodule("add",self._small_repo_url(),"module")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp