Artifact c9007e93066ac0fddd16a424aec1992611f15c4672b9c2981a88aa864892e2c7:


# type: test
# version: 0.2
# title: pyz lookups
#
# This is genuinely the most fragile part.
# Not the least testing it from outside the pyz package.
# Here `app.pyz/inner.py` must override its lookup __path__=[…]
# Fails from within test/xyz/ subdir

import sys
import os.path
import pytest
import pluginconf

sys.path.insert(0, f"{os.path.dirname(__file__)}/.pyz.pyz")
os.chdir(os.path.dirname(__file__))

pluginconf.module_base = ["config"]    # must be one of the .pyz-contained modules (should be a dir/submodule for real uses)
pluginconf.plugin_base = ["inner"]     # relative, must declare __path__, can't be __main__.py

@pytest.fixture
def pmd():
    return pluginconf.plugin_meta(module="inner")

def importy():
    import inner as pyz_inner
    #print(pyz_inner.__file__)

def module_list():
    assert set(pluginconf.module_list()) & {'__main__', 'config', 'inner'}

def inner_props(pmd):
    assert pmd["type"] == "pyz"
    assert pmd["category"] == "complex"
    assert pmd["title"] == "pyz module"
    assert pmd["config"][0]["name"] == "relation"
    assert pmd["state"] == "alpha"