Beispiel #1
0
def test_initpkg_nodoc(monkeypatch):
    mod = ModuleType("hello")
    mod.__file__ = "hello.py"
    monkeypatch.setitem(sys.modules, "hello", mod)
    apipkg.initpkg("hello", {})
    newmod = sys.modules["hello"]
    assert not newmod.__doc__
Beispiel #2
0
def test_initpkg_defaults(monkeypatch):
    mod = ModuleType("hello")
    monkeypatch.setitem(sys.modules, "hello", mod)
    apipkg.initpkg("hello", {})
    newmod = sys.modules["hello"]
    assert newmod.__file__ is None
    assert not hasattr(newmod, "__version__")
Beispiel #3
0
def test_initpkg_nodoc(monkeypatch):
    mod = ModuleType('hello')
    mod.__file__ = "hello.py"
    monkeypatch.setitem(sys.modules, 'hello', mod)
    apipkg.initpkg('hello', {})
    newmod = sys.modules['hello']
    assert not newmod.__doc__
Beispiel #4
0
def test_initpkg_defaults(monkeypatch):
    mod = ModuleType('hello')
    monkeypatch.setitem(sys.modules, 'hello', mod)
    apipkg.initpkg('hello', {})
    newmod = sys.modules['hello']
    assert newmod.__file__ is None
    assert not hasattr(newmod, '__version__')
Beispiel #5
0
def test_initpkg_replaces_sysmodules(monkeypatch):
    mod = ModuleType('hello')
    monkeypatch.setitem(sys.modules, 'hello', mod)
    apipkg.initpkg('hello', {'x': 'os.path:abspath'})
    newmod = sys.modules['hello']
    assert newmod != mod
    assert newmod.x == os.path.abspath
Beispiel #6
0
def test_initpkg_updates_sysmodules(monkeypatch):
    mod = ModuleType("hello")
    monkeypatch.setitem(sys.modules, "hello", mod)
    apipkg.initpkg("hello", {"x": "os.path:abspath"})
    newmod = sys.modules["hello"]
    assert (PY2 and newmod != mod) or (PY3 and newmod is mod)
    assert newmod.x == os.path.abspath
Beispiel #7
0
def test_initpkg_overwrite_doc(monkeypatch):
    hello = ModuleType("hello")
    hello.__doc__ = "this is the documentation"
    monkeypatch.setitem(sys.modules, "hello", hello)
    apipkg.initpkg("hello", {"__doc__": "sys:__doc__"})
    newhello = sys.modules["hello"]
    assert (PY2 and newhello != hello) or (PY3 and newhello is hello)
    assert newhello.__doc__ == sys.__doc__
Beispiel #8
0
def test_eagerload_on_bython(monkeypatch):
    monkeypatch.delitem(sys.modules, "bpython", raising=False)
    apipkg.initpkg("apipkg.testmodule.example.lazy",
                   {"test": "apipkg.does_not_exist"})
    monkeypatch.setitem(sys.modules, "bpython", True)
    with pytest.raises(ImportError):
        apipkg.initpkg("apipkg.testmodule.example.lazy",
                       {"test": "apipkg.does_not_exist"})
Beispiel #9
0
def test_eagerload_on_bython(monkeypatch):
    monkeypatch.delitem(sys.modules, 'bpython', raising=False)
    apipkg.initpkg('apipkg.testmodule.example.lazy',
                   {'test': 'apipkg.does_not_exist'})
    monkeypatch.setitem(sys.modules, 'bpython', True)
    with pytest.raises(ImportError):
        apipkg.initpkg('apipkg.testmodule.example.lazy',
                       {'test': 'apipkg.does_not_exist'})
Beispiel #10
0
def test_initpkg_overwrite_doc(monkeypatch):
    hello = ModuleType('hello')
    hello.__doc__ = "this is the documentation"
    monkeypatch.setitem(sys.modules, 'hello', hello)
    apipkg.initpkg('hello', {"__doc__": "sys:__doc__"})
    newhello = sys.modules['hello']
    assert newhello != hello
    assert newhello.__doc__ == sys.__doc__
Beispiel #11
0
def test_initpkg_not_transfers_not_existing_attrs(monkeypatch):
    mod = ModuleType('hello')
    mod.__file__ = "hello.py"
    assert not hasattr(mod, '__path__')
    monkeypatch.setitem(sys.modules, 'hello', mod)
    apipkg.initpkg('hello', {})
    newmod = sys.modules['hello']
    assert newmod != mod
    assert newmod.__file__ == py.path.local(mod.__file__)
    assert not hasattr(newmod, '__path__')
Beispiel #12
0
def test_initpkg_not_transfers_not_existing_attrs(monkeypatch):
    mod = ModuleType("hello")
    mod.__file__ = "hello.py"
    assert not hasattr(mod, "__path__")
    assert not hasattr(mod, "__package__") or mod.__package__ is None
    monkeypatch.setitem(sys.modules, "hello", mod)
    apipkg.initpkg("hello", {})
    newmod = sys.modules["hello"]
    assert (PY2 and newmod != mod) or (PY3 and newmod is mod)
    assert newmod.__file__ == os.path.abspath(mod.__file__)
    assert not hasattr(newmod, "__path__")
    assert not hasattr(newmod, "__package__") or mod.__package__ is None
Beispiel #13
0
def test_initpkg_not_changing_jython_paths(monkeypatch):
    mod = ModuleType("hello")
    mod.__file__ = "__pyclasspath__/test.py"
    mod.__path__ = ["__pyclasspath__/fun", "ichange"]
    monkeypatch.setitem(sys.modules, "hello", mod)
    apipkg.initpkg("hello", {})
    newmod = sys.modules["hello"]
    assert (PY2 and newmod != mod) or (PY3 and newmod is mod)
    assert newmod.__file__.startswith("__pyclasspath__")
    unchanged, changed = newmod.__path__
    assert changed != "ichange"
    assert unchanged.startswith("__pyclasspath__")
Beispiel #14
0
def test_initpkg_not_changing_jython_paths(monkeypatch):
    mod = ModuleType('hello')
    mod.__file__ = '__pyclasspath__/test.py'
    mod.__path__ = ['__pyclasspath__/fun', 'ichange']
    monkeypatch.setitem(sys.modules, 'hello', mod)
    apipkg.initpkg('hello', {})
    newmod = sys.modules['hello']
    assert newmod != mod
    assert newmod.__file__.startswith('__pyclasspath__')
    unchanged, changed = newmod.__path__
    assert changed != 'ichange'
    assert unchanged.startswith('__pyclasspath__')
Beispiel #15
0
def test_initpkg_transfers_attrs(monkeypatch):
    mod = ModuleType('hello')
    mod.__version__ = 10
    mod.__file__ = "hello.py"
    mod.__loader__ = "loader"
    mod.__doc__ = "this is the documentation"
    monkeypatch.setitem(sys.modules, 'hello', mod)
    apipkg.initpkg('hello', {})
    newmod = sys.modules['hello']
    assert newmod != mod
    assert newmod.__file__ == py.path.local(mod.__file__)
    assert newmod.__version__ == mod.__version__
    assert newmod.__loader__ == mod.__loader__
    assert newmod.__doc__ == mod.__doc__
Beispiel #16
0
def test_initpkg_transfers_attrs(monkeypatch):
    mod = ModuleType("hello")
    mod.__version__ = 10
    mod.__file__ = "hello.py"
    mod.__loader__ = "loader"
    mod.__package__ = "package"
    mod.__doc__ = "this is the documentation"
    mod.goodbye = "goodbye"
    monkeypatch.setitem(sys.modules, "hello", mod)
    apipkg.initpkg("hello", {})
    newmod = sys.modules["hello"]
    assert (PY2 and newmod != mod) or (PY3 and newmod is mod)
    assert newmod.__file__ == os.path.abspath(mod.__file__)
    assert newmod.__version__ == mod.__version__
    assert newmod.__loader__ == mod.__loader__
    assert newmod.__package__ == mod.__package__
    assert newmod.__doc__ == mod.__doc__
    assert not hasattr(newmod, "goodbye")
Beispiel #17
0
from apipkg import initpkg
initpkg(
    __name__,
    dict(
        jobs = "qs.jobs",
        proc = "qs.proc",
        qserve = "qs.qserve",
        rpcclient = "qs.rpcclient",
        rpcserver = "qs.rpcserver",
        slave = "qs.slave"))
Beispiel #18
0
#

import apipkg
apipkg.initpkg(__name__, {
    'EventReceiver'      : "xunitgen2._EventReceiver:EventReceiver",
    'Report'             : "xunitgen2._Report:Report",
    'XunitDestination'   : "xunitgen2._XunitDestination:XunitDestination",
    'Recorder'           : "xunitgen2._Recorder:Recorder",
    'XmlWriter'          : "xunitgen2._XmlWriter:XmlWriter",
    'toxml'              : "xunitgen2._XmlWriter:toxml",
})
Beispiel #19
0
#

import apipkg
apipkg.initpkg(__name__, {
    'commands': {
        "HelpCommand": "clish._commands._HelpCommand:HelpCommand",
        "ExitCommand": "clish._commands._ExitCommand:ExitCommand",
    },

    'Namespace': "clish._Namespace:Namespace",
    'Command'  : "clish._Command:Command",
    'Shell'    : "clish._Shell:Shell",

    # DEPRECATE NAMES
    'InteractiveCommand' : "clish._Command:Command",
    'InteractiveShell'   : "clish._Shell:Shell",
})
Beispiel #20
0
-------

pure python lib for connecting to local and remote Python Interpreters.

(c) 2012, Holger Krekel and others
"""
import apipkg

apipkg.initpkg(
    __name__, {
        '__version__': '._version:version',
        'PopenGateway': '.deprecated:PopenGateway',
        'SocketGateway': '.deprecated:SocketGateway',
        'SshGateway': '.deprecated:SshGateway',
        'makegateway': '.multi:makegateway',
        'set_execmodel': '.multi:set_execmodel',
        'HostNotFound': '.gateway_bootstrap:HostNotFound',
        'RemoteError': '.gateway_base:RemoteError',
        'TimeoutError': '.gateway_base:TimeoutError',
        'XSpec': '.xspec:XSpec',
        'Group': '.multi:Group',
        'MultiChannel': '.multi:MultiChannel',
        'RSync': '.rsync:RSync',
        'default_group': '.multi:default_group',
        'dumps': '.gateway_base:dumps',
        'loads': '.gateway_base:loads',
        'load': '.gateway_base:load',
        'dump': '.gateway_base:dump',
        'DataFormatError': '.gateway_base:DataFormatError',
    })
Beispiel #21
0
def test_importlib_find_spec_fake_module(find_spec):
    mod = apipkg.initpkg("apipkg.testmodule.example.missing", {})
    with pytest.raises(ValueError, match=mod.__name__ + r"\.__spec__ is None"):
        find_spec(mod.__name__)
Beispiel #22
0
# mypkg/__init__.py
import apipkg

apipkg.initpkg(
    __name__,
    {
        "SomeClass": "_mypkg.somemodule:SomeClass",
        "sub": {
            "OtherClass": "_mypkg.somemodule:OtherClass",
        },
    },
)
Beispiel #23
0
"""
    anyvc
    ~~~~~~

    pythonic vcs abstractions

    :license: LPL2
    :copyright: Ronny Pfannschmidt and others
"""

import apipkg
apipkg.initpkg(
    __name__, {
        'workdir': {
            'clone': 'anyvc._workdir:clone',
            'checkout': 'anyvc._workdir:checkout',
            'open': 'anyvc._workdir:open',
        },
    })
Beispiel #24
0
import codecs
from collections import namedtuple
import logging
import os
import re
from six.moves import configparser

import apipkg
import pytest

from pycsw.core import admin
from pycsw.core.config import StaticContext

apipkg.initpkg("optionaldependencies", {
    "psycopg2": "psycopg2",
})

from optionaldependencies import psycopg2  # NOQA: E402

TESTS_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

SuiteDirs = namedtuple("SuiteDirs", [
    "get_tests_dir",
    "post_tests_dir",
    "data_tests_dir",
    "expected_results_dir",
    "export_tests_dir",
])

Beispiel #25
0
exports = dict(
    capturing = 'ExceptionCapture OutputCapture',
    config = 'Config',
    diffing = 'TreeDiffer JSONDiffer PrettyDiffer YAMLDiffer DataDiffer',
    environment = 'Environment',
    expecting = 'MustRaise',
    importing = 'BlockingImporter AssertionLoggingImporter',
    representing = 'AttributeRepr TreeRepr',
    running = 'Runner TerminalRunner',
    suite = 'ConfigSuite Suite fixture generator test',
)


defs = {}
for module, members in exports.iteritems():
    for member in members.split():
        defs[member] = ''.join(['_detest.', module, ':', member])


defs.update(
    paver = dict(
        auto = '_detest.paver:auto',
        test = '_detest.paver:test',
    )
)


import apipkg
apipkg.initpkg(__name__, defs)
Beispiel #26
0
execnet
-------

pure python lib for connecting to local and remote Python Interpreters.

(c) 2012, Holger Krekel and others
"""
import apipkg

apipkg.initpkg(__name__, {
    '__version__':      '._version:version',
    'PopenGateway':     '.deprecated:PopenGateway',
    'SocketGateway':    '.deprecated:SocketGateway',
    'SshGateway':       '.deprecated:SshGateway',
    'makegateway':      '.multi:makegateway',
    'set_execmodel':    '.multi:set_execmodel',
    'HostNotFound':     '.gateway_bootstrap:HostNotFound',
    'RemoteError':      '.gateway_base:RemoteError',
    'TimeoutError':     '.gateway_base:TimeoutError',
    'XSpec':            '.xspec:XSpec',
    'Group':            '.multi:Group',
    'MultiChannel':     '.multi:MultiChannel',
    'RSync':            '.rsync:RSync',
    'default_group':    '.multi:default_group',
    'dumps':            '.gateway_base:dumps',
    'loads':            '.gateway_base:loads',
    'load':             '.gateway_base:load',
    'dump':             '.gateway_base:dump',
    'DataFormatError':  '.gateway_base:DataFormatError',
})
Beispiel #27
0
#

import apipkg

apipkg.initpkg(
    __name__,
    {
        'commands': {
            "HelpCommand": "clish._commands._HelpCommand:HelpCommand",
            "ExitCommand": "clish._commands._ExitCommand:ExitCommand",
        },
        'Namespace': "clish._Namespace:Namespace",
        'Command': "clish._Command:Command",
        'Shell': "clish._Shell:Shell",

        # DEPRECATE NAMES
        'InteractiveCommand': "clish._Command:Command",
        'InteractiveShell': "clish._Shell:Shell",
    })
Beispiel #28
0
# mypkg/__init__.py

import apipkg
apipkg.initpkg(
    __name__, {
        'SomeClass': '_mypkg.somemodule:SomeClass',
        'sub': {
            'OtherClass': '_mypkg.somemodule:OtherClass',
        }
    })
Beispiel #29
0
Datei: lazy.py Projekt: dag/rag
from apipkg import initpkg

initpkg(
    __name__,
    dict(
        rst='rag.documents.rst',
        fs='rag.histories.fs',
        git='rag.histories.git',
        scss='rag.stylesheets.scss',
        genshi='rag.templates.genshi',
        bare='rag.sites.bare',
        Site='rag.sites.default:Site',
    ))
Beispiel #30
0
Datei: lazy.py Projekt: dag/rag
from apipkg import initpkg

initpkg(__name__,
    dict(
        rst='rag.documents.rst',
        fs='rag.histories.fs',
        git='rag.histories.git',
        scss='rag.stylesheets.scss',
        genshi='rag.templates.genshi',
        bare='rag.sites.bare',
        Site='rag.sites.default:Site',
    )
)
Beispiel #31
0
def test_initpkg_without_old_module():
    apipkg.initpkg("initpkg_without_old_module", dict(modules="sys:modules"))
    from initpkg_without_old_module import modules

    assert modules is sys.modules
Beispiel #32
0
pure python lib for connecting to local and remote Python Interpreters.

(c) 2012, Holger Krekel and others
"""
import apipkg

apipkg.initpkg(
    __name__,
    {
        "__version__": "._version:version",
        "PopenGateway": ".deprecated:PopenGateway",
        "SocketGateway": ".deprecated:SocketGateway",
        "SshGateway": ".deprecated:SshGateway",
        "makegateway": ".multi:makegateway",
        "set_execmodel": ".multi:set_execmodel",
        "HostNotFound": ".gateway_bootstrap:HostNotFound",
        "RemoteError": ".gateway_base:RemoteError",
        "TimeoutError": ".gateway_base:TimeoutError",
        "XSpec": ".xspec:XSpec",
        "Group": ".multi:Group",
        "MultiChannel": ".multi:MultiChannel",
        "RSync": ".rsync:RSync",
        "default_group": ".multi:default_group",
        "dumps": ".gateway_base:dumps",
        "loads": ".gateway_base:loads",
        "load": ".gateway_base:load",
        "dump": ".gateway_base:dump",
        "DataFormatError": ".gateway_base:DataFormatError",
    },
)
Beispiel #33
0
from apipkg import initpkg
initpkg(
    __name__,
    dict(jobs="qs.jobs",
         proc="qs.proc",
         qserve="qs.qserve",
         rpcclient="qs.rpcclient",
         rpcserver="qs.rpcserver",
         slave="qs.slave"))
Beispiel #34
0
import codecs
from collections import namedtuple
import logging
import os
import re
import configparser

import apipkg
import pytest

from pycsw.core import admin
from pycsw.core.config import StaticContext

apipkg.initpkg("optionaldependencies", {
    "psycopg2": "psycopg2",
})

from optionaldependencies import psycopg2  # NOQA: E402

TESTS_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

SuiteDirs = namedtuple("SuiteDirs", [
    "get_tests_dir",
    "post_tests_dir",
    "data_tests_dir",
    "expected_results_dir",
    "export_tests_dir",
])

Beispiel #35
0
from apipkg            import initpkg
from ramverk.inventory import members


api = {}
for module, names in members.iteritems():
    for name in names:
        assert name not in api
        api[name] = ':'.join([module, name])


initpkg(__name__, api)