File: test_advanced.py

package info (click to toggle)
python-pluginbase 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 268 kB
  • sloc: python: 537; makefile: 118
file content (20 lines) | stat: -rw-r--r-- 537 bytes parent folder | download | duplicates (3)
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')