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

Commit96fc354

Browse files
committed
Add tests for current Submodule.iter_items behavior
Where the behavior is intended.In the case of an invalid hash (or IOError, which in Python 2 wasa subclass of OSError but now is just another name for it), thebehavior of just yielding no items may be unintuitive, since onmost other errors an exception is raised.However, examining the code reveals this behavior is clearlyintentional. Furthrmore, it may be reasonable for applications torely on it, and it may be convenient in some situations. Forbackward compatibility, it probably can't be changed significantly.This adds tests that show both an error that does raise anerror-representing exception -- a well-formed hash not present inthe repository raising ValueError with a suitable message -- and anerror that silently causes the iterator to yield zero items.
1 parent53e7383 commit96fc354

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎test/test_submodule.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,17 @@ def test_root_module(self, rwrepo):
688688
# gitdb: has either 1 or 2 submodules depending on the version.
689689
assertlen(nsm.children())>=1andnsmc.module_exists()
690690

691+
deftest_iter_items_from_nonexistent_hash(self):
692+
it=Submodule.iter_items(self.rorepo,"b4ecbfaa90c8be6ed6d9fb4e57cc824663ae15b4")
693+
withself.assertRaisesRegex(ValueError,r"\bcould not be resolved\b"):
694+
next(it)
695+
696+
deftest_iter_items_from_invalid_hash(self):
697+
"""Check legacy behavaior on BadName (also applies to IOError, i.e. OSError)."""
698+
it=Submodule.iter_items(self.rorepo,"xyz")
699+
withself.assertRaises(StopIteration):
700+
next(it)
701+
691702
@with_rw_repo(k_no_subm_tag,bare=False)
692703
deftest_first_submodule(self,rwrepo):
693704
assertlen(list(rwrepo.iter_submodules()))==0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp