From 2a2f888909e31f4fc9d26593a4addffd75469dd0 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 1 Aug 2018 07:30:40 -0300 Subject: [PATCH] Move recursive_map from local to free function --- src/_pytest/python_api.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 66b9473b7..25b76742c 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -101,20 +101,20 @@ class ApproxBase(object): pass +def recursive_map(f, x): + if isinstance(x, list): + return list(recursive_map(f, xi) for xi in x) + else: + return f(x) + + class ApproxNumpy(ApproxBase): """ Perform approximate comparisons where the expected value is numpy array. """ def __repr__(self): - def recursive_map(f, x): - if isinstance(x, list): - return list(recursive_map(f, xi) for xi in x) - else: - return f(x) - list_scalars = recursive_map(self._approx_scalar, self.expected.tolist()) - return "approx({!r})".format(list_scalars) if sys.version_info[0] == 2: