diff --git a/skimage/measure/tests/test_marching_cubes.py b/skimage/measure/tests/test_marching_cubes.py index a9d59a21..5cce3ea8 100644 --- a/skimage/measure/tests/test_marching_cubes.py +++ b/skimage/measure/tests/test_marching_cubes.py @@ -8,30 +8,32 @@ from skimage.measure import (marching_cubes, mesh_surface_area, correct_mesh_orientation) from skimage.measure._marching_cubes_lewiner import _expected_output_args +def func_that_knows_about_its_outputs(r): + # Must be defined in global scope to avoid syntax error on Python 2 *sigh* + nout = _expected_output_args() + print(nout) + r.append(nout) + return [nout] * int(nout) + def test_expected_output_args(): + foo = func_that_knows_about_its_outputs + res = [] - - def foo(): - nout = _expected_output_args() - print(nout) - res.append(nout) - return [nout] * int(nout) - - foo() - a = foo() - a, b = foo() - a, b, c = foo() + foo(res) + a = foo(res) + a, b = foo(res) + a, b, c = foo(res) assert res == [0, 1, 2, 3] or res == [0, 0, 2, 3] # ``a = foo()`` somehow yields 0 in test, which is ok for us; # we only want to distinguish between > 2 args or not if sys.version_info >= (3, 3): res = [] - exec('*a, b, c = foo()') - exec('a, b, c, *d = foo()') - exec('a, b, *c, d, e = foo()') + exec('*a, b, c = foo(res)') + exec('a, b, c, *d = foo(res)') + exec('a, b, *c, d, e = foo(res)') assert res == [2.1, 3.1, 4.1]