pytest: Use the py.test utility if available

The py.test unit test runner offers a number of more advanced features
than simply running using unittest.main. In particular it allows us to
capture a tests output and print it if it fails. This change checks
whether we have pytest available and if yes, enables verbose tests and
runs using pytest. This'll give the usual experience (with colors!)
and show us the stdout if a test fails making travis a lot easier to
handle.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2017-11-09 14:36:56 +01:00 committed by Rusty Russell
parent 5320cab2de
commit fc176b6cc0

View file

@ -29,6 +29,8 @@ ifeq ($(COVERAGE),1)
COVFLAGS = --coverage
endif
PYTEST := $(shell command -v pytest 2> /dev/null)
# This is where we add new features as bitcoin adds them.
FEATURES :=
@ -170,7 +172,11 @@ check:
$(MAKE) pytest
pytest: $(ALL_PROGRAMS)
ifndef PYTEST
PYTHONPATH=contrib/pylightning DEVELOPER=$(DEVELOPER) python3 tests/test_lightningd.py -f
else
PYTHONPATH=contrib/pylightning TEST_DEBUG=1 DEVELOPER=$(DEVELOPER) $(PYTEST) -vx tests/test_lightningd.py
endif
# Keep includes in alpha order.
check-src-include-order/%: %