From bb3cbc894a194e2e59e6ac5735e923c8e315a43f Mon Sep 17 00:00:00 2001 From: mloubout Date: Thu, 20 Jun 2024 15:40:46 -0400 Subject: [PATCH] CI: tweak docstring test to avoid repr issues on some system --- conftest.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/conftest.py b/conftest.py index 4bb06293271..c67198edf43 100644 --- a/conftest.py +++ b/conftest.py @@ -1,5 +1,6 @@ import os import sys +import builtins from subprocess import check_call import pytest @@ -453,3 +454,18 @@ def check_array(array, exp_halo, exp_shape, rotate=False): assert tuple(array.halo) == exp_halo assert tuple(shape) == tuple(exp_shape) + + +# Custom display hook that uses __str__ to avoid docstring test issues +def custom_display_hook(value): + if value is not None: + builtins._ = value + print(str(value)) + + +@pytest.fixture(scope='session', autouse=True) +def use_str_display_hook(): + original_display_hook = sys.displayhook + sys.displayhook = custom_display_hook + yield + sys.displayhook = original_display_hook # Restore original display hook after tests