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

Commit9113177

Browse files
committed
Don't swallow AttributeError from super().setUp()
This is conceptually independent of the immediately precedingsuper() call refactoring, but serves the same goal of simplifyingand clarifying super() calls.In test.performance.lib, the TestBigRepoR and TestBigRepoRWclasses' setUp methods had calls to setUp through super proxies,which were wrapped in try-blocks to swallow AttributeErrorexceptions. This removes that, relying on the presence of setUpmethods in some parent or sibling class in the MRO.The intent appeared to be solely to account for the possibilitythat no class in the MRO would define a setUp method. However,the unittest.TestCase base class defines noop setUp and tearDownmethods to ensure this does not have to be done.This may also make the code more robust, because the form in whichAttributeError was being swallowed was: try: super().setUp() except AttributeError: passBut that has the disadvantage of also catching AttributeError dueto a bug or other problem in code that runs *in* an ancestor orsibling class's existing setUp method. This could alternativelybe addressed by using: try: other_setUp = super().setUp except AttributeError: pass else: other_setUp()However, because unittest.TestCase provides empty setUp andtearDown methods to allow such special-casing to be avoided (bothin cases like this and for the test runner), this isn't needed.
1 parenta47e46d commit9113177

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

‎test/performance/lib.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ class TestBigRepoR(TestBase):
3232
"""
3333

3434
defsetUp(self):
35-
try:
36-
super().setUp()
37-
exceptAttributeError:
38-
pass
35+
super().setUp()
3936

4037
repo_path=os.environ.get(k_env_git_repo)
4138
ifrepo_pathisNone:
@@ -64,10 +61,7 @@ class TestBigRepoRW(TestBigRepoR):
6461

6562
defsetUp(self):
6663
self.gitrwrepo=None
67-
try:
68-
super().setUp()
69-
exceptAttributeError:
70-
pass
64+
super().setUp()
7165
dirname=tempfile.mktemp()
7266
os.mkdir(dirname)
7367
self.gitrwrepo=self.gitrorepo.clone(dirname,shared=True,bare=True,odbt=GitCmdObjectDB)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp