Skip to content

Commit 8308fbd

Browse files
authored
Merge pull request #888 from planetlabs/py3.10-warnings-882
Fix Py3.10 test warnings
2 parents b93f4f1 + 745884f commit 8308fbd

File tree

14 files changed

+150
-156
lines changed

14 files changed

+150
-156
lines changed

noxfile.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ def test(session):
4242
session.install(".[test]")
4343

4444
options = session.posargs
45-
session.run('pytest', '--ignore', 'examples/', '-v', *options)
45+
# -W=error raises pytest warnings to errors so they are caught by CI
46+
# to exclude some warnings, see
47+
# https://docs.python.org/3/library/warnings.html#temporarily-suppressing-warnings
48+
session.run('pytest', '--ignore', 'examples/', '-v', '-W=error', *options)
4649

4750

4851
@nox.session

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
install_requires = [
2727
'click>=8.0.0',
2828
'geojson',
29-
'httpx==0.23.0',
29+
'httpx>=0.23.0',
3030
'jsonschema',
3131
'pyjwt>=2.1',
3232
'tqdm>=4.56',
3333
'typing-extensions',
3434
]
3535

36-
test_requires = ['pytest', 'pytest-asyncio==0.16', 'pytest-cov', 'respx==0.19']
36+
test_requires = ['pytest', 'anyio', 'pytest-cov', 'respx>=0.20']
3737

3838
lint_requires = ['flake8', 'mypy', 'yapf']
3939

tests/conftest.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def get_test_file_json():
5050

5151
def func(filename):
5252
file_path = _test_data_path / filename
53-
return json.load(open(file_path, 'r'))
53+
with open(file_path, 'r') as f:
54+
res = json.load(f)
55+
return res
5456

5557
return func
5658

@@ -147,3 +149,8 @@ def multipolygon_geom_geojson():
147149
[37.791595458984375, 14.945448293647944],
148150
[37.791595458984375, 14.84923123791421]]]]
149151
} # yapf: disable
152+
153+
154+
@pytest.fixture
155+
def anyio_backend():
156+
return 'asyncio'

tests/integration/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_disable_limiter(monkeypatch):
2828

2929

3030
@pytest.fixture
31-
@pytest.mark.asyncio
31+
@pytest.mark.anyio
3232
async def session():
3333
async with planet.Session() as ps:
3434
yield ps

tests/integration/test_data_api.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def search_response(item_descriptions):
7171

7272

7373
@respx.mock
74-
@pytest.mark.asyncio
74+
@pytest.mark.anyio
7575
async def test_search_basic(item_descriptions, search_response, session):
7676

7777
quick_search_url = f'{TEST_URL}/quick-search'
@@ -105,7 +105,7 @@ async def test_search_basic(item_descriptions, search_response, session):
105105

106106

107107
@respx.mock
108-
@pytest.mark.asyncio
108+
@pytest.mark.anyio
109109
async def test_search_name(item_descriptions, search_response, session):
110110

111111
quick_search_url = f'{TEST_URL}/quick-search'
@@ -141,7 +141,7 @@ async def test_search_name(item_descriptions, search_response, session):
141141

142142

143143
@respx.mock
144-
@pytest.mark.asyncio
144+
@pytest.mark.anyio
145145
async def test_search_filter(item_descriptions,
146146
search_filter,
147147
search_response,
@@ -178,7 +178,7 @@ async def test_search_filter(item_descriptions,
178178

179179

180180
@respx.mock
181-
@pytest.mark.asyncio
181+
@pytest.mark.anyio
182182
async def test_search_sort(item_descriptions,
183183
search_filter,
184184
search_response,
@@ -201,7 +201,7 @@ async def test_search_sort(item_descriptions,
201201

202202

203203
@respx.mock
204-
@pytest.mark.asyncio
204+
@pytest.mark.anyio
205205
async def test_search_limit(item_descriptions,
206206
search_filter,
207207
search_response,
@@ -226,7 +226,7 @@ async def test_search_limit(item_descriptions,
226226

227227

228228
@respx.mock
229-
@pytest.mark.asyncio
229+
@pytest.mark.anyio
230230
async def test_create_search_basic(search_filter, session):
231231

232232
page_response = {
@@ -264,7 +264,7 @@ async def test_create_search_basic(search_filter, session):
264264

265265

266266
@respx.mock
267-
@pytest.mark.asyncio
267+
@pytest.mark.anyio
268268
async def test_create_search_email(search_filter, session):
269269

270270
page_response = {
@@ -303,7 +303,7 @@ async def test_create_search_email(search_filter, session):
303303

304304

305305
@respx.mock
306-
@pytest.mark.asyncio
306+
@pytest.mark.anyio
307307
async def test_get_search_success(search_id, search_result, session):
308308
get_url = f'{TEST_SEARCHES_URL}/{search_id}'
309309
mock_resp = httpx.Response(HTTPStatus.OK, json=search_result)
@@ -314,7 +314,7 @@ async def test_get_search_success(search_id, search_result, session):
314314

315315

316316
@respx.mock
317-
@pytest.mark.asyncio
317+
@pytest.mark.anyio
318318
async def test_get_search_id_doesnt_exist(search_id, session):
319319
get_url = f'{TEST_SEARCHES_URL}/{search_id}'
320320

@@ -331,7 +331,7 @@ async def test_get_search_id_doesnt_exist(search_id, session):
331331

332332

333333
@respx.mock
334-
@pytest.mark.asyncio
334+
@pytest.mark.anyio
335335
async def test_update_search_basic(search_filter, session):
336336

337337
page_response = {
@@ -370,7 +370,7 @@ async def test_update_search_basic(search_filter, session):
370370

371371

372372
@respx.mock
373-
@pytest.mark.asyncio
373+
@pytest.mark.anyio
374374
@pytest.mark.parametrize("limit, expected_list_length", [(None, 4), (3, 3)])
375375
async def test_list_searches_success(limit,
376376
expected_list_length,
@@ -389,7 +389,7 @@ async def test_list_searches_success(limit,
389389

390390

391391
@respx.mock
392-
@pytest.mark.asyncio
392+
@pytest.mark.anyio
393393
@pytest.mark.parametrize("sort, rel_url",
394394
[(LIST_SORT_DEFAULT, ''),
395395
('created asc', '?_sort=created+asc')])
@@ -405,7 +405,7 @@ async def test_list_searches_sort(sort, rel_url, search_result, session):
405405

406406

407407
@respx.mock
408-
@pytest.mark.asyncio
408+
@pytest.mark.anyio
409409
@pytest.mark.parametrize("search_type, rel_url",
410410
[(LIST_SEARCH_TYPE_DEFAULT, ''),
411411
('saved', '?search_type=saved')])
@@ -424,7 +424,7 @@ async def test_list_searches_searchtype(search_type,
424424

425425

426426
@respx.mock
427-
@pytest.mark.asyncio
427+
@pytest.mark.anyio
428428
@pytest.mark.parametrize(
429429
"sort, search_type, expectation",
430430
[('DOESNOTEXIST', 'ANY', pytest.raises(exceptions.ClientError)),
@@ -445,7 +445,7 @@ async def test_list_searches_args_do_not_match(sort,
445445

446446

447447
@respx.mock
448-
@pytest.mark.asyncio
448+
@pytest.mark.anyio
449449
@pytest.mark.parametrize("retcode, expectation",
450450
[(204, does_not_raise()),
451451
(404, pytest.raises(exceptions.APIError))])
@@ -462,7 +462,7 @@ async def test_delete_search(retcode, expectation, session):
462462

463463

464464
@respx.mock
465-
@pytest.mark.asyncio
465+
@pytest.mark.anyio
466466
@pytest.mark.parametrize("search_id, valid", [(VALID_SEARCH_ID, True),
467467
('invalid', False)])
468468
@pytest.mark.parametrize("limit, expected_count", [(None, 3), (2, 2)])
@@ -503,7 +503,7 @@ async def test_run_search_basic(item_descriptions,
503503

504504

505505
@respx.mock
506-
@pytest.mark.asyncio
506+
@pytest.mark.anyio
507507
@pytest.mark.parametrize("sort, rel_url, valid",
508508
[(SEARCH_SORT_DEFAULT, '', True),
509509
('acquired asc', '?_sort=acquired+asc', True),
@@ -540,7 +540,7 @@ async def test_run_search_sort(item_descriptions,
540540

541541

542542
@respx.mock
543-
@pytest.mark.asyncio
543+
@pytest.mark.anyio
544544
async def test_run_search_doesnotexist(session):
545545
route = respx.get(f'{TEST_SEARCHES_URL}/{VALID_SEARCH_ID}/results')
546546
route.return_value = httpx.Response(404)
@@ -553,7 +553,7 @@ async def test_run_search_doesnotexist(session):
553553

554554

555555
@respx.mock
556-
@pytest.mark.asyncio
556+
@pytest.mark.anyio
557557
async def test_get_stats_success(search_filter, session):
558558

559559
page_response = {
@@ -587,7 +587,7 @@ async def test_get_stats_success(search_filter, session):
587587

588588

589589
@respx.mock
590-
@pytest.mark.asyncio
590+
@pytest.mark.anyio
591591
async def test_get_stats_invalid_interval(search_filter, session):
592592
cl = DataClient(session, base_url=TEST_URL)
593593

@@ -596,7 +596,7 @@ async def test_get_stats_invalid_interval(search_filter, session):
596596

597597

598598
@respx.mock
599-
@pytest.mark.asyncio
599+
@pytest.mark.anyio
600600
async def test_list_item_assets_success(session):
601601
item_type_id = 'PSScene'
602602
item_id = '20221003_002705_38_2461'
@@ -640,7 +640,7 @@ async def test_list_item_assets_success(session):
640640

641641

642642
@respx.mock
643-
@pytest.mark.asyncio
643+
@pytest.mark.anyio
644644
async def test_list_item_assets_missing(session):
645645
item_type_id = 'PSScene'
646646
item_id = '20221003_002705_38_2461xx'
@@ -656,7 +656,7 @@ async def test_list_item_assets_missing(session):
656656

657657

658658
@respx.mock
659-
@pytest.mark.asyncio
659+
@pytest.mark.anyio
660660
@pytest.mark.parametrize("asset_type_id, expectation",
661661
[('basic_udm2', does_not_raise()),
662662
('invalid', pytest.raises(exceptions.ClientError))])
@@ -706,7 +706,7 @@ async def test_get_asset(asset_type_id, expectation, session):
706706

707707

708708
@respx.mock
709-
@pytest.mark.asyncio
709+
@pytest.mark.anyio
710710
@pytest.mark.parametrize("status, expectation", [('inactive', True),
711711
('active', False)])
712712
async def test_activate_asset_success(status, expectation, session):
@@ -735,7 +735,7 @@ async def test_activate_asset_success(status, expectation, session):
735735

736736

737737
@respx.mock
738-
@pytest.mark.asyncio
738+
@pytest.mark.anyio
739739
async def test_activate_asset_invalid_asset(session):
740740
cl = DataClient(session, base_url=TEST_URL)
741741

@@ -744,7 +744,7 @@ async def test_activate_asset_invalid_asset(session):
744744

745745

746746
@respx.mock
747-
@pytest.mark.asyncio
747+
@pytest.mark.anyio
748748
async def test_wait_asset_success(session):
749749
asset_url = f'{TEST_URL}/asset'
750750

@@ -777,7 +777,7 @@ async def test_wait_asset_success(session):
777777

778778

779779
@respx.mock
780-
@pytest.mark.asyncio
780+
@pytest.mark.anyio
781781
async def test_wait_asset_max_attempts(session):
782782
asset_url = f'{TEST_URL}/asset'
783783

@@ -806,7 +806,7 @@ async def test_wait_asset_max_attempts(session):
806806

807807

808808
@respx.mock
809-
@pytest.mark.asyncio
809+
@pytest.mark.anyio
810810
@pytest.mark.parametrize("exists, overwrite",
811811
[(False, False), (True, False), (True, True),
812812
(False, True)])
@@ -873,7 +873,7 @@ async def _stream_img():
873873

874874

875875
@respx.mock
876-
@pytest.mark.asyncio
876+
@pytest.mark.anyio
877877
@pytest.mark.parametrize("hashes_match, md5_entry, expectation",
878878
[(True, True, does_not_raise()),
879879
(False, True, pytest.raises(exceptions.ClientError)),

0 commit comments

Comments
 (0)