summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apscheduler/job.py4
-rw-r--r--apscheduler/util.py2
-rw-r--r--tests/conftest.py5
-rw-r--r--tests/test_job.py33
4 files changed, 30 insertions, 14 deletions
diff --git a/apscheduler/job.py b/apscheduler/job.py
index afbbe12..5cc8ae8 100644
--- a/apscheduler/job.py
+++ b/apscheduler/job.py
@@ -50,7 +50,7 @@ class Job(object):
args = changes.pop('args') if 'args' in changes else self.args
kwargs = changes.pop('kwargs') if 'kwargs' in changes else self.kwargs
- if isinstance(func, six.string_types):
+ if isinstance(func, str):
func_ref = func
func = ref_to_obj(func)
elif callable(func):
@@ -313,7 +313,7 @@ class JobHandle(object):
return '<JobHandle (id=%s name=%s)>' % (repr_escape(self.id), repr_escape(self.name))
def __str__(self):
- return '%s (trigger: %s, next run at: %s)' % (self.name, repr_escape(str(self.trigger)),
+ return '%s (trigger: %s, next run at: %s)' % (repr_escape(self.name), repr_escape(str(self.trigger)),
datetime_repr(self.next_run_time))
def __unicode__(self):
diff --git a/apscheduler/util.py b/apscheduler/util.py
index f99367c..b999ecc 100644
--- a/apscheduler/util.py
+++ b/apscheduler/util.py
@@ -242,7 +242,7 @@ def maybe_ref(ref):
if six.PY2:
def repr_escape(string):
if isinstance(string, unicode):
- return string.encode('ascii', errors='backslashreplace')
+ return string.encode('ascii', 'backslashreplace')
return string
else:
repr_escape = lambda string: string
diff --git a/tests/conftest.py b/tests/conftest.py
index ade909f..3a3c027 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,3 +1,4 @@
+# coding: utf-8
from datetime import datetime
import sys
@@ -68,8 +69,8 @@ def freeze_time(monkeypatch, timezone):
def job_defaults(timezone):
run_date = datetime(2011, 4, 3, 18, 40, tzinfo=timezone)
return {'trigger': 'date', 'trigger_args': {'run_date': run_date, 'timezone': timezone}, 'executor': 'default',
- 'args': (), 'kwargs': {}, 'id': 'testid', 'misfire_grace_time': 1, 'coalesce': False, 'name': None,
- 'max_runs': None, 'max_instances': 1}
+ 'args': (), 'kwargs': {}, 'id': b't\xc3\xa9st\xc3\xafd'.decode('utf-8'), 'misfire_grace_time': 1,
+ 'coalesce': False, 'name': b'n\xc3\xa4m\xc3\xa9'.decode('utf-8'), 'max_runs': None, 'max_instances': 1}
@pytest.fixture(scope='session')
diff --git a/tests/test_job.py b/tests/test_job.py
index b2c1f5f..0681e98 100644
--- a/tests/test_job.py
+++ b/tests/test_job.py
@@ -1,7 +1,8 @@
+# coding: utf-8
from datetime import datetime, timedelta
+from pip._vendor import six
import pytest
-import six
from apscheduler.job import Job, JobHandle
from apscheduler.triggers.date import DateTrigger
@@ -57,9 +58,11 @@ class TestJob(object):
def test_getstate(self, job):
state = job.__getstate__()
- assert state == dict(version=1, trigger=job.trigger, executor='default', func='tests.test_job:dummyfunc',
- name='dummyfunc', args=(), kwargs={}, id='testid', misfire_grace_time=1, coalesce=False,
- max_runs=None, max_instances=1, runs=0, next_run_time=None)
+ expected = dict(version=1, trigger=job.trigger, executor='default', func='tests.test_job:dummyfunc',
+ name=b'n\xc3\xa4m\xc3\xa9'.decode('utf-8'), args=(), kwargs={},
+ id=b't\xc3\xa9st\xc3\xafd'.decode('utf-8'), misfire_grace_time=1, coalesce=False,
+ max_runs=None, max_instances=1, runs=0, next_run_time=None)
+ assert state == expected
def test_setstate(self, job, timezone):
trigger = DateTrigger('2010-12-14 13:05:00', timezone)
@@ -91,7 +94,10 @@ class TestJob(object):
assert not job == 'bleh'
def test_job_repr(self, job):
- assert repr(job) == '<Job (id=testid)>'
+ if six.PY2:
+ assert repr(job) == '<Job (id=t\\xe9st\\xefd)>'
+ else:
+ assert repr(job) == b'<Job (id=t\xc3\xa9st\xc3\xafd)>'.decode('utf-8')
class TestJobHandle(object):
@@ -147,12 +153,21 @@ class TestJobHandle(object):
assert not jobhandle == 'bah'
def test_jobhandle_repr(self, jobhandle):
- assert repr(jobhandle) == '<JobHandle (id=testid name=dummyfunc)>'
+ if six.PY2:
+ assert repr(jobhandle) == '<JobHandle (id=t\\xe9st\\xefd name=n\\xe4m\\xe9)>'
+ else:
+ assert repr(jobhandle) == b'<JobHandle (id=t\xc3\xa9st\xc3\xafd name=n\xc3\xa4m\xc3\xa9)>'.decode('utf-8')
def test_jobhandle_str(self, jobhandle):
- assert str(jobhandle) == 'dummyfunc (trigger: date[2011-04-03 18:40:00 DUMMYTZ], next run at: None)'
+ if six.PY2:
+ expected = 'n\\xe4m\\xe9 (trigger: date[2011-04-03 18:40:00 DUMMYTZ], next run at: None)'
+ else:
+ expected = b'n\xc3\xa4m\xc3\xa9 (trigger: date[2011-04-03 18:40:00 DUMMYTZ], next run at: None)'.\
+ decode('utf-8')
+
+ assert str(jobhandle) == expected
@maxpython(3, 0)
def test_jobhandle_unicode(self, jobhandle):
- assert jobhandle.__unicode__() == six.u(
- 'dummyfunc (trigger: date[2011-04-03 18:40:00 DUMMYTZ], next run at: None)')
+ assert jobhandle.__unicode__() == \
+ b'n\xc3\xa4m\xc3\xa9 (trigger: date[2011-04-03 18:40:00 DUMMYTZ], next run at: None)'.decode('utf-8')