From fc176b6cc071c3276a306286848dd38cc8239f72 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Thu, 9 Nov 2017 14:36:56 +0100 Subject: [PATCH] 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 --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 66ae00c55..04c3d5628 100644 --- a/Makefile +++ b/Makefile @@ -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/%: %