Skip to content

Commit 74ceae9

Browse files
committed
cmd/git(fix[GitTag]): make doctests self-contained
why: Doctests failed in full test suite due to state pollution - tags created in earlier doctests don't persist across different test contexts what: - GitTagCmd.run: use 'in' check instead of exact match - GitTagManager.__init__: create own tag before verifying - GitTagManager.run: create own tag before verifying
1 parent 6c3d65a commit 74ceae9

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/libvcs/cmd/git.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5885,11 +5885,12 @@ def run(
58855885
... name='test-tag', message='Test tag'
58865886
... )
58875887
''
5888-
>>> GitTagCmd(
5888+
>>> result = GitTagCmd(
58895889
... path=example_git_repo.path,
58905890
... tag_name='test-tag',
58915891
... ).run()
5892-
'test-tag'
5892+
>>> 'test-tag' in result
5893+
True
58935894
"""
58945895
local_flags = local_flags if isinstance(local_flags, list) else []
58955896
if command is not None:
@@ -6030,10 +6031,11 @@ def __init__(
60306031
>>> GitTagManager(path=tmp_path).run()
60316032
'fatal: not a git repository (or any of the parent directories): .git'
60326033
6033-
>>> GitTagManager(
6034-
... path=example_git_repo.path
6035-
... ).run()
6034+
>>> mgr = GitTagManager(path=example_git_repo.path)
6035+
>>> mgr.create(name='init-doctest-tag', message='For doctest')
60366036
''
6037+
>>> 'init-doctest-tag' in mgr.run()
6038+
True
60376039
"""
60386040
#: Directory to check out
60396041
self.path: pathlib.Path
@@ -6064,8 +6066,11 @@ def run(
60646066
60656067
Examples
60666068
--------
6067-
>>> GitTagManager(path=example_git_repo.path).run()
6069+
>>> mgr = GitTagManager(path=example_git_repo.path)
6070+
>>> mgr.create(name='run-doctest-tag', message='For doctest')
60686071
''
6072+
>>> 'run-doctest-tag' in mgr.run()
6073+
True
60696074
"""
60706075
local_flags = local_flags if isinstance(local_flags, list) else []
60716076
if command is not None:

0 commit comments

Comments
 (0)