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>
This commit is contained in:
Christian Decker
2018-11-21 11:29:59 +01:00
committed by Rusty Russell
parent 45e1f09714
commit 522c3039ec

View File

@@ -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