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

Commitc09ac1a

Browse files
committed
Test InvalidGitRepositoryError in repo subdir
A Repo object can of course be constructed from a path to adirectory that is the root of an existing repository, and raisesInvalidGitRepositoryError on a directory that is outside of anyrepository. Tests intended to show both conditions already exist.This adds a test to verify that InvalidGitRepositoryError is alsoraised when an attempt is made to construct a Repo object from apath to a directory that is not the root of a repository but thatis known to be located inside an existing git repository.
1 parent9277ff5 commitc09ac1a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎test/test_repo.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,20 @@ def tearDown(self):
7777
gc.collect()
7878

7979
deftest_new_should_raise_on_invalid_repo_location(self):
80+
# Ideally this tests a directory that is outside of any repository. In the rare
81+
# case tempfile.gettempdir() is inside a repo, this still passes, but tests the
82+
# same scenario as test_new_should_raise_on_invalid_repo_location_within_repo.
8083
withtempfile.TemporaryDirectory()astdir:
8184
self.assertRaises(InvalidGitRepositoryError,Repo,tdir)
8285

86+
@with_rw_directory
87+
deftest_new_should_raise_on_invalid_repo_location_within_repo(self,rw_dir):
88+
repo_dir=osp.join(rw_dir,"repo")
89+
Repo.init(repo_dir)
90+
subdir=osp.join(repo_dir,"subdir")
91+
os.mkdir(subdir)
92+
self.assertRaises(InvalidGitRepositoryError,Repo,subdir)
93+
8394
deftest_new_should_raise_on_non_existent_path(self):
8495
withtempfile.TemporaryDirectory()astdir:
8596
nonexistent=osp.join(tdir,"foobar")
@@ -122,7 +133,7 @@ def test_tree_from_revision(self):
122133
self.assertEqual(tree.type,"tree")
123134
self.assertEqual(self.rorepo.tree(tree),tree)
124135

125-
#try from invalid revision that does not exist
136+
#Try fromaninvalid revision that does not exist.
126137
self.assertRaises(BadName,self.rorepo.tree,"hello world")
127138

128139
deftest_pickleable(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp