@@ -70,14 +70,15 @@ def set_config(app, mapping):
7070
7171
7272@mock .patch ('sphinx.ext.intersphinx._load.InventoryFile' )
73- @mock .patch ('sphinx.ext.intersphinx._load._read_from_url ' )
73+ @mock .patch ('sphinx.ext.intersphinx._load.requests.get ' )
7474@pytest .mark .sphinx ('html' , testroot = 'root' )
75- def test_fetch_inventory_redirection (_read_from_url , InventoryFile , app ): # NoQA: PT019
75+ def test_fetch_inventory_redirection (get_request , InventoryFile , app ):
76+ mocked_get = get_request .return_value .__enter__ .return_value
7677 intersphinx_setup (app )
77- _read_from_url (). readline . return_value = b'# Sphinx inventory version 2'
78+ mocked_get . content = b'# Sphinx inventory version 2'
7879
7980 # same uri and inv, not redirected
80- _read_from_url () .url = 'https://hostname/' + INVENTORY_FILENAME
81+ mocked_get .url = 'https://hostname/' + INVENTORY_FILENAME
8182 _fetch_inventory (
8283 target_uri = 'https://hostname/' ,
8384 inv_location = 'https://hostname/' + INVENTORY_FILENAME ,
@@ -90,7 +91,7 @@ def test_fetch_inventory_redirection(_read_from_url, InventoryFile, app): # NoQ
9091 # same uri and inv, redirected
9192 app .status .seek (0 )
9293 app .status .truncate (0 )
93- _read_from_url () .url = 'https://hostname/new/' + INVENTORY_FILENAME
94+ mocked_get .url = 'https://hostname/new/' + INVENTORY_FILENAME
9495
9596 _fetch_inventory (
9697 target_uri = 'https://hostname/' ,
@@ -108,7 +109,7 @@ def test_fetch_inventory_redirection(_read_from_url, InventoryFile, app): # NoQ
108109 # different uri and inv, not redirected
109110 app .status .seek (0 )
110111 app .status .truncate (0 )
111- _read_from_url () .url = 'https://hostname/new/' + INVENTORY_FILENAME
112+ mocked_get .url = 'https://hostname/new/' + INVENTORY_FILENAME
112113
113114 _fetch_inventory (
114115 target_uri = 'https://hostname/' ,
@@ -122,7 +123,7 @@ def test_fetch_inventory_redirection(_read_from_url, InventoryFile, app): # NoQ
122123 # different uri and inv, redirected
123124 app .status .seek (0 )
124125 app .status .truncate (0 )
125- _read_from_url () .url = 'https://hostname/other/' + INVENTORY_FILENAME
126+ mocked_get .url = 'https://hostname/other/' + INVENTORY_FILENAME
126127
127128 _fetch_inventory (
128129 target_uri = 'https://hostname/' ,
0 commit comments