File test/sources.py artifact 07c00096f5 part of check-in 97eec56287


# type: test
# title: frame=
# description: test alternative source aqusition
# ok: 1

import pytest
import pluginconf
import sys

def _pmd(**kwargs):
    return pluginconf.plugin_meta(**kwargs)

def frame_1():
    assert _pmd(frame=1)["ok"]

def frame_0():
    # should resolve to pluginconf/__init__.py
    assert _pmd(frame=0)["title"] == "Plugin configuration"

def src():
    # requires trailing newline
    assert _pmd(src="# id: empty\n")["id"] == "empty"

def module_pc_init():
    pluginconf.plugin_base = ["pluginconf", "."]
    assert _pmd(module="__init__")["category"] == "config"

def module_test():
    # requires __init__.py in test/
    pluginconf.plugin_base = ["test"]
    assert _pmd(module="sources")["ok"]