#!/usr/bin/make -f

export PYBUILD_NAME=urllib3
export PYTHONWARNINGS=d
# Use patched hypercorn; see https://github.com/urllib3/urllib3/issues/3334
export PYTHONPATH=$(CURDIR)/debian/vendor
export PYBUILD_TEST_PYTEST=1
export PYBUILD_TEST_ARGS=-m 'not requires_network'
# This test fails if urllib3.connection.RECENT_DATE hasn't been updated
# recently enough, which would be a problem for stable releases.
PYBUILD_TEST_ARGS += --deselect test/test_connection.py::TestConnection::test_recent_date
# These tests fail due to recent changes in Python:
# https://github.com/urllib3/urllib3/issues/5268
PYBUILD_TEST_ARGS += \
	--deselect test/test_response.py::TestResponse::test_chunked_decoding_gzip_swallow_garbage \
	--deselect 'test/test_response.py::TestResponse::test_read_chunked_with_trailing_data_does_not_hang[gzip]'
export LC_ALL=C.UTF-8
export CI=1  # Use longer timeouts, see https://github.com/urllib3/urllib3/issues/3164
# pybuild exports http_proxy=http://127.0.0.1:9/ by default, but that breaks
# some tests here and the package doesn't seem to try to connect to the
# internet without it.
export http_proxy=

%:
	dh $@ --buildsystem=pybuild

override_dh_clean:
	dh_clean
	find . -type d -name .pytest_cache -exec rm -rf {} +

override_dh_auto_test:
	PYTHONPATH=$(CURDIR)/debian/vendor dh_auto_test

override_dh_installchangelogs:
	dh_installchangelogs CHANGES.rst
