Skip to content

Commit

Permalink
CI: tweak docstring test to avoid repr issues on some system
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Jun 22, 2024
1 parent cc48c36 commit bb3cbc8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
import builtins
from subprocess import check_call

import pytest
Expand Down Expand Up @@ -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

0 comments on commit bb3cbc8

Please sign in to comment.