From 522c3039ec64f00049585fd6493861d3dd544783 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 21 Nov 2018 11:29:59 +0100 Subject: [PATCH] pytest: Pretty print the memleak output in tests It wasn't JSON formatted either so there was no nice pretty-printing way. This jsonifies and pretty prints it. Signed-off-by: Christian Decker <@cdecker> --- tests/utils.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index d7c8545a8..440f631d6 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,3 +1,10 @@ +from bitcoin.rpc import RawProxy as BitcoinProxy +from btcproxy import BitcoinRpcProxy +from decimal import Decimal +from ephemeral_port_reserve import reserve +from lightning import LightningRpc + +import json import logging import os import random @@ -9,12 +16,6 @@ import subprocess import threading import time -from btcproxy import BitcoinRpcProxy -from bitcoin.rpc import RawProxy as BitcoinProxy -from decimal import Decimal -from ephemeral_port_reserve import reserve -from lightning import LightningRpc - BITCOIND_CONFIG = { "regtest": 1, "rpcuser": "rpcuser", @@ -864,7 +865,9 @@ class NodeFactory(object): unexpected_fail = True if leaks is not None and len(leaks) != 0: - raise Exception("Node {} has memory leaks: {}" - .format(self.nodes[i].daemon.lightning_dir, leaks)) + raise Exception("Node {} has memory leaks: {}".format( + self.nodes[i].daemon.lightning_dir, + json.dumps(leaks, sort_keys=True, indent=4) + )) return not unexpected_fail