File tree 1 file changed +3
-12
lines changed
1 file changed +3
-12
lines changed Original file line number Diff line number Diff line change @@ -37,18 +37,12 @@ def test_lazy_import_basics():
37
37
# Now test that accessing attributes does what it should
38
38
assert math .sin (math .pi ) == pytest .approx (0 , 1e-6 )
39
39
# poor-mans pytest.raises for testing errors on attribute access
40
- try :
40
+ with pytest . raises ( ModuleNotFoundError ) :
41
41
anything_not_real .pi
42
- raise AssertionError () # Should not get here
43
- except ModuleNotFoundError :
44
- pass
45
42
assert isinstance (anything_not_real , lazy .DelayedImportErrorModule )
46
43
# see if it changes for second access
47
- try :
44
+ with pytest . raises ( ModuleNotFoundError ) :
48
45
anything_not_real .pi
49
- raise AssertionError () # Should not get here
50
- except ModuleNotFoundError :
51
- pass
52
46
53
47
54
48
def test_lazy_import_subpackages ():
@@ -88,11 +82,8 @@ def test_lazy_import_nonbuiltins():
88
82
if not isinstance (np , lazy .DelayedImportErrorModule ):
89
83
assert np .sin (np .pi ) == pytest .approx (0 , 1e-6 )
90
84
if isinstance (sp , lazy .DelayedImportErrorModule ):
91
- try :
85
+ with pytest . raises ( ModuleNotFoundError ) :
92
86
sp .pi
93
- raise AssertionError ()
94
- except ModuleNotFoundError :
95
- pass
96
87
97
88
98
89
def test_lazy_attach ():
You can’t perform that action at this time.
0 commit comments