This repository was archived by the owner on Aug 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55
66def test_invalid_format ():
7- with pytest .raises (ImportFromStringError ) as exc :
7+ with pytest .raises (ImportFromStringError ) as exc_info :
88 import_from_string ("example:" )
99 expected = 'Import string "example:" must be in format "<module>:<attribute>".'
10- assert expected in str (exc )
10+ assert expected in str (exc_info . value )
1111
1212
1313def test_invalid_module ():
14- with pytest .raises (ImportFromStringError ) as exc :
14+ with pytest .raises (ImportFromStringError ) as exc_info :
1515 import_from_string ("module_does_not_exist:myattr" )
1616 expected = 'Could not import module "module_does_not_exist".'
17- assert expected in str (exc )
17+ assert expected in str (exc_info . value )
1818
1919
2020def test_invalid_attr ():
21- with pytest .raises (ImportFromStringError ) as exc :
21+ with pytest .raises (ImportFromStringError ) as exc_info :
2222 import_from_string ("tempfile:attr_does_not_exist" )
2323 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 )
2525
2626
2727def test_internal_import_error ():
28- with pytest .raises (ImportError ) as exc :
28+ with pytest .raises (ImportError ):
2929 import_from_string ("tests.importer.raise_import_error:myattr" )
3030
3131
You can’t perform that action at this time.
0 commit comments