File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 4
4
5
5
6
6
def test_invalid_format ():
7
- with pytest .raises (ImportFromStringError ) as exc :
7
+ with pytest .raises (ImportFromStringError ) as exc_info :
8
8
import_from_string ("example:" )
9
9
expected = 'Import string "example:" must be in format "<module>:<attribute>".'
10
- assert expected in str (exc )
10
+ assert expected in str (exc_info . value )
11
11
12
12
13
13
def test_invalid_module ():
14
- with pytest .raises (ImportFromStringError ) as exc :
14
+ with pytest .raises (ImportFromStringError ) as exc_info :
15
15
import_from_string ("module_does_not_exist:myattr" )
16
16
expected = 'Could not import module "module_does_not_exist".'
17
- assert expected in str (exc )
17
+ assert expected in str (exc_info . value )
18
18
19
19
20
20
def test_invalid_attr ():
21
- with pytest .raises (ImportFromStringError ) as exc :
21
+ with pytest .raises (ImportFromStringError ) as exc_info :
22
22
import_from_string ("tempfile:attr_does_not_exist" )
23
23
expected = 'Attribute "attr_does_not_exist" not found in module "tempfile".'
24
- assert expected in str (exc )
24
+ assert expected in str (exc_info . value )
25
25
26
26
27
27
def test_internal_import_error ():
28
- with pytest .raises (ImportError ) as exc :
28
+ with pytest .raises (ImportError ):
29
29
import_from_string ("tests.importer.raise_import_error:myattr" )
30
30
31
31
You can’t perform that action at this time.
0 commit comments