summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2014-07-01 10:12:10 +0200
committerArmin Ronacher <armin.ronacher@active-4.com>2014-07-01 10:12:10 +0200
commitc398d967e0281540d84e4ba2c14424eb1944288a (patch)
treec0638db9dda2a0998854d470c88511dad905559d /tests
parent08f0c0b112e6cdaa7dbf2e830c7fe95f513acd6d (diff)
downloadpluginbase-c398d967e0281540d84e4ba2c14424eb1944288a.tar.gz
Added support for loading resources.
Diffstat (limited to 'tests')
-rw-r--r--tests/plugins/withresources/__init__.py2
-rw-r--r--tests/plugins/withresources/hello.txt1
-rw-r--r--tests/test_advanced.py12
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')