summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2016-11-06 10:40:50 +0200
committerAlex Grönholm <alex.gronholm@nextday.fi>2016-11-06 10:40:50 +0200
commitf075d15c141ad9ae6ea7b4873db3e8acbc18627d (patch)
tree6b2a21bd73a933fee710f4d5eaeaa8dcde33e875 /tests
parent0802351ef10e37fa82ed2da76fa25779c5f87ee3 (diff)
downloadapscheduler-f075d15c141ad9ae6ea7b4873db3e8acbc18627d.tar.gz
Fixed @scheduled_job not playing nice with persistent job stores (fixes #150)
Diffstat (limited to 'tests')
-rw-r--r--tests/test_job.py5
-rw-r--r--tests/test_util.py20
2 files changed, 18 insertions, 7 deletions
diff --git a/tests/test_job.py b/tests/test_job.py
index f13c612..9dc9210 100644
--- a/tests/test_job.py
+++ b/tests/test_job.py
@@ -1,5 +1,6 @@
# coding: utf-8
from datetime import datetime, timedelta
+from functools import partial
import pytest
import six
@@ -120,9 +121,7 @@ def test_private_modify_func_ref(job):
def test_private_modify_unreachable_func(job):
"""Tests that func_ref remains None if no reference to the target callable can be found."""
- def func():
- pass
-
+ func = partial(dummyfunc)
job._modify(func=func)
assert job.func is func
assert job.func_ref is None
diff --git a/tests/test_util.py b/tests/test_util.py
index 44ebd4e..75f6e42 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -190,10 +190,22 @@ class TestGetCallableName(object):
class TestObjToRef(object):
- @pytest.mark.parametrize('input', [partial(DummyClass.meth)], ids=['partial/bound method'])
- def test_no_ref_found(self, input):
- exc = pytest.raises(ValueError, obj_to_ref, input)
- assert 'Cannot determine the reference to ' in str(exc.value)
+ @pytest.mark.parametrize('obj, error', [
+ (partial(DummyClass.meth), 'Cannot create a reference to a partial()'),
+ (lambda: None, 'Cannot create a reference to a lambda')
+ ], ids=['partial', 'lambda'])
+ def test_errors(self, obj, error):
+ exc = pytest.raises(ValueError, obj_to_ref, obj)
+ assert str(exc.value) == error
+
+ @pytest.mark.skipif(sys.version_info[:2] < (3, 3),
+ reason='Requires __qualname__ (Python 3.3+)')
+ def test_nested_function_error(self):
+ def nested():
+ pass
+
+ exc = pytest.raises(ValueError, obj_to_ref, nested)
+ assert str(exc.value) == 'Cannot create a reference to a nested function'
@pytest.mark.parametrize('input,expected', [
pytest.mark.skipif(sys.version_info[:2] == (3, 2),