Skip to content

Commit

Permalink
Try with asyncio detection
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne committed Sep 18, 2024
1 parent 35ab907 commit b8e0f03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ethstaker_deposit/utils/terminal.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import subprocess
import os
import sys
import shutil
import click


def clear_terminal() -> None:
if sys.platform == 'win32':
try:
subprocess.call('cls', shell=True)
except Exception:
# Special-case for asyncio pytest on Windows
if os.getenv("IS_ASYNC_TEST") == "1":
click.clear()
elif shutil.which('clear'):
subprocess.call(['clear'])
else:
os.system('cls')
elif sys.platform == 'linux' or sys.platform == 'darwin':
if shutil.which('tput'):
subprocess.call(['tput', 'reset'])
Expand Down
9 changes: 9 additions & 0 deletions tests/test_cli/test_new_mnemonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys

import pytest
import inspect
from click.testing import CliRunner

from eth_utils import decode_hex
Expand All @@ -20,6 +21,14 @@
from .helpers import clean_key_folder, get_permissions, get_uuid


@pytest.fixture(autouse=True)
def check_async(request):
if inspect.iscoroutinefunction(request.node.obj):
os.environ['IS_ASYNC_TEST'] = '1'
else:
os.environ['IS_ASYNC_TEST'] = '0'


def test_new_mnemonic_bls_withdrawal(monkeypatch) -> None:
# monkeypatch get_mnemonic
def mock_get_mnemonic(language, words_path, entropy=None) -> str:
Expand Down

0 comments on commit b8e0f03

Please sign in to comment.