Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Commit9113177
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
1 file changed
+2
-8
lines changedLines changed: 2 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
32 | 32 |
| |
33 | 33 |
| |
34 | 34 |
| |
35 |
| - | |
36 |
| - | |
37 |
| - | |
38 |
| - | |
| 35 | + | |
39 | 36 |
| |
40 | 37 |
| |
41 | 38 |
| |
| |||
64 | 61 |
| |
65 | 62 |
| |
66 | 63 |
| |
67 |
| - | |
68 |
| - | |
69 |
| - | |
70 |
| - | |
| 64 | + | |
71 | 65 |
| |
72 | 66 |
| |
73 | 67 |
| |
|
0 commit comments
Comments
(0)