33from pathlib import Path
44
55import os
6- import httpretty
6+ import responses
77
8- from httpretty import httprettified
98from opencage .geocoder import OpenCageGeocode
109
1110# reduce maximum backoff retry time from 120s to 1s
@@ -22,51 +21,54 @@ def _any_result_around(results, lat=None, lon=None):
2221 return True
2322 return False
2423
25- @httprettified
24+ @responses . activate
2625def test_gb_postcode ():
27- httpretty . register_uri (
28- httpretty .GET ,
26+ responses . add (
27+ responses .GET ,
2928 geocoder .url ,
30- body = Path ('test/fixtures/uk_postcode.json' ).read_text (encoding = "utf-8" )
29+ body = Path ('test/fixtures/uk_postcode.json' ).read_text (encoding = "utf-8" ),
30+ status = 200
3131 )
3232
3333 results = geocoder .geocode ("EC1M 5RF" )
3434 assert _any_result_around (results , lat = 51.5201666 , lon = - 0.0985142 )
3535
3636
37- @httprettified
37+ @responses . activate
3838def test_australia ():
39- httpretty . register_uri (
40- httpretty .GET ,
39+ responses . add (
40+ responses .GET ,
4141 geocoder .url ,
42- body = Path ('test/fixtures/mudgee_australia.json' ).read_text (encoding = "utf-8" )
42+ body = Path ('test/fixtures/mudgee_australia.json' ).read_text (encoding = "utf-8" ),
43+ status = 200
4344 )
4445
4546 results = geocoder .geocode ("Mudgee, Australia" )
4647 assert _any_result_around (results , lat = - 32.5980702 , lon = 149.5886383 )
4748
4849
49- @httprettified
50+ @responses . activate
5051def test_munster ():
51- httpretty . register_uri (
52- httpretty .GET ,
52+ responses . add (
53+ responses .GET ,
5354 geocoder .url ,
54- body = Path ('test/fixtures/muenster.json' ).read_text (encoding = "utf-8" )
55+ body = Path ('test/fixtures/muenster.json' ).read_text (encoding = "utf-8" ),
56+ status = 200
5557 )
5658
5759 results = geocoder .geocode ("Münster" )
5860 assert _any_result_around (results , lat = 51.9625101 , lon = 7.6251879 )
5961
60- @httprettified
62+ @responses . activate
6163def test_donostia ():
62- httpretty . register_uri (
63- httpretty .GET ,
64+ responses . add (
65+ responses .GET ,
6466 geocoder .url ,
65- body = Path ('test/fixtures/donostia.json' ).read_text (encoding = "utf-8" )
66-
67+ body = Path ('test/fixtures/donostia.json' ).read_text (encoding = "utf-8" ),
68+ status = 200
6769 )
6870
69- results = geocoder .geocode ("Donostia" )
71+ results = geocoder .geocode ("Donostia" )
7072 assert _any_result_around (results , lat = 43.300836 , lon = - 1.9809529 )
7173
7274 # test that the results are in unicode
0 commit comments