#! /usr/bin/make -f

export PYBUILD_NAME=httpx
export PYBUILD_DISABLE=test

# Use dynamic port for unittest embedded webservers
# Also see debian/patches/0000-Debianize-unittests-run
# export HTTPX_TEST_HTTP_PORT=$(shell python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')
# export HTTPX_TEST_HTTPS_PORT=$(shell python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')

%:
	dh $@ --with python3 --buildsystem=pybuild

# override_dh_auto_test:
# ifeq ($(filter nocheck,$(DEB_BUILD_PROFILES)),)
# 	$(info Running unittest with HTTP on port $(HTTPX_TEST_HTTP_PORT) and HTTPS one on $(HTTPX_TEST_HTTPS_PORT))
# 	# For some reasons dh_auto_test sets a lot of environment variables and I have not been able to find
# 	# any documentation or the code setting this, what I'm sure of, is that it breaks unittest checking proxy
# 	# state, let's forget about this and call pytest directly, it's a lot easier
# 	# The three additional disabled test are making remote calls
# 	# http_proxy='' https_proxy='' dh_auto_test
# 	for python in $(shell py3versions --supported); do \
# 	  $$python -m pytest -v -k 'not test_connect_timeout and not test_sync_proxy_close and not test_async_proxy_close'; \
# 	done
# endif
