diff options
author | Armin Ronacher <armin.ronacher@active-4.com> | 2014-07-01 10:12:10 +0200 |
---|---|---|
committer | Armin Ronacher <armin.ronacher@active-4.com> | 2014-07-01 10:12:10 +0200 |
commit | c398d967e0281540d84e4ba2c14424eb1944288a (patch) | |
tree | c0638db9dda2a0998854d470c88511dad905559d /tests | |
parent | 08f0c0b112e6cdaa7dbf2e830c7fe95f513acd6d (diff) | |
download | pluginbase-c398d967e0281540d84e4ba2c14424eb1944288a.tar.gz |
Added support for loading resources.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/plugins/withresources/__init__.py | 2 | ||||
-rw-r--r-- | tests/plugins/withresources/hello.txt | 1 | ||||
-rw-r--r-- | tests/test_advanced.py | 12 |
3 files changed, 15 insertions, 0 deletions
diff --git a/tests/plugins/withresources/__init__.py b/tests/plugins/withresources/__init__.py new file mode 100644 index 0000000..9332a27 --- /dev/null +++ b/tests/plugins/withresources/__init__.py @@ -0,0 +1,2 @@ +def foo(): + pass diff --git a/tests/plugins/withresources/hello.txt b/tests/plugins/withresources/hello.txt new file mode 100644 index 0000000..a670a4e --- /dev/null +++ b/tests/plugins/withresources/hello.txt @@ -0,0 +1 @@ +I am a textfile. diff --git a/tests/test_advanced.py b/tests/test_advanced.py index d6440a5..15f668f 100644 --- a/tests/test_advanced.py +++ b/tests/test_advanced.py @@ -1,3 +1,6 @@ +import pytest + + def test_custom_state(base): class App(object): name = 'foobar' @@ -6,3 +9,12 @@ def test_custom_state(base): 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') |