summaryrefslogtreecommitdiff
path: root/tests/test_advanced.py
blob: 15f668f2989ad7e98e5bfb1b0b9d8249590888cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pytest


def test_custom_state(base):
    class App(object):
        name = 'foobar'
    source = base.make_plugin_source(searchpath=['./plugins'])
    source.app = App()

    plg = source.load_plugin('advanced')
    assert plg.get_app_name() == 'foobar'


def test_plugin_resources(source):
    with source.open_resource('withresources', 'hello.txt') as f:
        contents = f.read()
    assert contents == b'I am a textfile.\n'

    with pytest.raises(IOError):
        source.open_resource('withresources', 'missingfile.txt')