def stub_indy() -> Stub:
    # detect indy module
    try:
        from indy.libindy import _cdll

        _cdll()

        return Stub(None)
    except ImportError:
        print(
            "Skipping Indy-specific tests: python3-indy module not installed.")
    except OSError:
        print(
            "Skipping Indy-specific tests: libindy shared library could not be loaded."
        )

    modules = {}
    package_name = "indy"
    modules[package_name] = mock.MagicMock()
    for mod in [
            "anoncreds",
            "blob_storage",
            "crypto",
            "did",
            "error",
            "pool",
            "ledger",
            "non_secrets",
            "pairwise",
            "wallet",
    ]:
        submod = f"{package_name}.{mod}"
        modules[submod] = mock.MagicMock()
    return Stub(mock.patch.dict(sys.modules, modules))
Exemple #2
0
def require_indy():
    try:
        from indy.libindy import _cdll

        _cdll()
    except ImportError:
        print("python3-indy module not installed")
        sys.exit(1)
    except OSError:
        print("libindy shared library could not be loaded")
        sys.exit(1)
def pytest_sessionstart(session):
    global INDY_FOUND, INDY_STUB, POSTGRES_URL

    # detect indy module
    try:
        from indy.libindy import _cdll

        _cdll()

        INDY_FOUND = True
    except ImportError:
        print(
            "Skipping Indy-specific tests: python3-indy module not installed.")
    except OSError:
        print(
            "Skipping Indy-specific tests: libindy shared library could not be loaded."
        )

    if not INDY_FOUND:
        modules = {}
        package_name = "indy"
        modules[package_name] = mock.MagicMock()
        for mod in [
                "anoncreds",
                "blob_storage",
                "crypto",
                "did",
                "error",
                "pool",
                "ledger",
                "non_secrets",
                "pairwise",
                "wallet",
        ]:
            submod = f"{package_name}.{mod}"
            modules[submod] = mock.MagicMock()
        INDY_STUB = mock.patch.dict(sys.modules, modules)
        INDY_STUB.start()

    POSTGRES_URL = os.getenv("POSTGRES_URL")
Exemple #4
0
import pytest

try:
    from indy.libindy import _cdll

    _cdll()
except ImportError:
    pytest.skip(
        "skipping Indy-specific tests: python module not installed",
        allow_module_level=True,
    )
except OSError:
    pytest.skip(
        "skipping Indy-specific tests: shared library not loaded",
        allow_module_level=True,
    )

from indy_catalyst_agent.wallet.basic import BasicWallet
from indy_catalyst_agent.wallet.indy import IndyWallet

from . import test_basic_wallet


@pytest.fixture()
async def basic_wallet():
    wallet = BasicWallet()
    await wallet.open()
    yield wallet
    await wallet.close()