Skip to content

Commit

Permalink
All test cases now inherits from celery.tests.utils.Case
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed Jan 26, 2012
1 parent 2a82e85 commit cf42285
Show file tree
Hide file tree
Showing 53 changed files with 158 additions and 166 deletions.
4 changes: 2 additions & 2 deletions celery/tests/functional/case.py
Expand Up @@ -15,7 +15,7 @@
from celery.task.control import ping, flatten_reply, inspect
from celery.utils import qualname

from celery.tests.utils import unittest
from celery.tests.utils import Case

HOSTNAME = socket.gethostname()

Expand Down Expand Up @@ -103,7 +103,7 @@ def _ensure_shutdown_once():
return worker


class WorkerCase(unittest.TestCase):
class WorkerCase(Case):
hostname = HOSTNAME
worker = None

Expand Down
14 changes: 7 additions & 7 deletions celery/tests/test_app/__init__.py
Expand Up @@ -15,7 +15,7 @@
from celery.utils.serialization import pickle

from celery.tests import config
from celery.tests.utils import (unittest, mask_modules, platform_pyimp,
from celery.tests.utils import (Case, mask_modules, platform_pyimp,
sys_platform, pypy_version)
from celery.utils.mail import ErrorMail
from kombu.utils import gen_unique_id
Expand All @@ -38,7 +38,7 @@ def _get_test_config():
test_config = _get_test_config()


class test_App(unittest.TestCase):
class test_App(Case):

def setUp(self):
self.app = Celery(set_as_current=False)
Expand Down Expand Up @@ -254,13 +254,13 @@ def test_error_mail_sender(self):
self.assertTrue(x)


class test_BaseApp(unittest.TestCase):
class test_BaseApp(Case):

def test_on_init(self):
BaseApp()


class test_defaults(unittest.TestCase):
class test_defaults(Case):

def test_str_to_bool(self):
for s in ("false", "no", "0"):
Expand All @@ -271,7 +271,7 @@ def test_str_to_bool(self):
defaults.str_to_bool("unsure")


class test_debugging_utils(unittest.TestCase):
class test_debugging_utils(Case):

def test_enable_disable_trace(self):
try:
Expand All @@ -283,7 +283,7 @@ def test_enable_disable_trace(self):
_app.disable_trace()


class test_compilation(unittest.TestCase):
class test_compilation(Case):
_clean = ("celery.app.base", )

def setUp(self):
Expand All @@ -299,7 +299,7 @@ def test_kombu_version_check(self):
__import__("celery.app.base")


class test_pyimplementation(unittest.TestCase):
class test_pyimplementation(Case):

def test_platform_python_implementation(self):
with platform_pyimp(lambda: "Xython"):
Expand Down
6 changes: 3 additions & 3 deletions celery/tests/test_app/test_annotations.py
Expand Up @@ -4,7 +4,7 @@
from celery.task import task
from celery.utils import qualname

from celery.tests.utils import unittest
from celery.tests.utils import Case


@task
Expand All @@ -21,7 +21,7 @@ class MyAnnotation(object):
foo = 65


class test_MapAnnotation(unittest.TestCase):
class test_MapAnnotation(Case):

def test_annotate(self):
x = MapAnnotation({add.name: {"foo": 1}})
Expand All @@ -36,7 +36,7 @@ def test_annotate_any(self):
self.assertIsNone(x.annotate_any())


class test_prepare(unittest.TestCase):
class test_prepare(Case):

def test_dict_to_MapAnnotation(self):
x = prepare({add.name: {"foo": 3}})
Expand Down
4 changes: 2 additions & 2 deletions celery/tests/test_app/test_app_defaults.py
Expand Up @@ -5,10 +5,10 @@

from importlib import import_module

from celery.tests.utils import unittest, pypy_version, sys_platform
from celery.tests.utils import Case, pypy_version, sys_platform


class test_defaults(unittest.TestCase):
class test_defaults(Case):

def setUp(self):
self._prev = sys.modules.pop("celery.app.defaults", None)
Expand Down
10 changes: 5 additions & 5 deletions celery/tests/test_app/test_beat.py
Expand Up @@ -11,7 +11,7 @@
from celery.schedules import schedule
from celery.task.base import Task
from celery.utils import uuid
from celery.tests.utils import unittest
from celery.tests.utils import Case


class Object(object):
Expand Down Expand Up @@ -43,7 +43,7 @@ def stop(self, **kwargs):
self.stopped = True


class test_ScheduleEntry(unittest.TestCase):
class test_ScheduleEntry(Case):
Entry = beat.ScheduleEntry

def create_entry(self, **kwargs):
Expand Down Expand Up @@ -150,7 +150,7 @@ def is_due(self, last_run_at):
always_pending = mocked_schedule(False, 1)


class test_Scheduler(unittest.TestCase):
class test_Scheduler(Case):

def test_custom_schedule_dict(self):
custom = {"foo": "bar"}
Expand Down Expand Up @@ -248,7 +248,7 @@ def test_merge_inplace(self):
self.assertEqual(a.schedule["bar"].schedule._next_run_at, 40)


class test_Service(unittest.TestCase):
class test_Service(Case):

def get_service(self):
sh = MockShelve()
Expand Down Expand Up @@ -317,7 +317,7 @@ def test_start_manages_one_tick_before_shutdown(self):
self.assertTrue(s._is_shutdown.isSet())


class test_EmbeddedService(unittest.TestCase):
class test_EmbeddedService(Case):

def test_start_stop_process(self):
try:
Expand Down
4 changes: 2 additions & 2 deletions celery/tests/test_app/test_celery.py
@@ -1,10 +1,10 @@
from __future__ import absolute_import
from celery.tests.utils import unittest
from celery.tests.utils import Case

import celery


class TestInitFile(unittest.TestCase):
class TestInitFile(Case):

def test_version(self):
self.assertTrue(celery.VERSION)
Expand Down
7 changes: 3 additions & 4 deletions celery/tests/test_app/test_log.py
Expand Up @@ -12,12 +12,11 @@
setup_logging_subsystem)
from celery.utils import uuid
from celery.utils.compat import _CompatLoggerAdapter
from celery.tests.utils import unittest
from celery.tests.utils import (override_stdouts, wrap_logger,
from celery.tests.utils import (Case, override_stdouts, wrap_logger,
get_handlers, set_handlers)


class test_default_logger(unittest.TestCase):
class test_default_logger(Case):

def setUp(self):
self.setup_logger = setup_logger
Expand Down Expand Up @@ -144,7 +143,7 @@ def isEnabledFor(self, level):
return True


class test_CompatLoggerAdapter(unittest.TestCase):
class test_CompatLoggerAdapter(Case):
levels = ("debug",
"info",
"warn", "warning",
Expand Down
8 changes: 4 additions & 4 deletions celery/tests/test_app/test_routes.py
Expand Up @@ -7,7 +7,7 @@
from celery import current_app
from celery.exceptions import QueueNotFound
from celery.utils import maybe_promise
from celery.tests.utils import unittest
from celery.tests.utils import Case


def E(queues):
Expand Down Expand Up @@ -47,7 +47,7 @@ def __inner(*args, **kwargs):
"routing_key": current_app.conf.CELERY_DEFAULT_ROUTING_KEY}


class test_MapRoute(unittest.TestCase):
class test_MapRoute(Case):

@with_queues(foo=a_queue, bar=b_queue)
def test_route_for_task_expanded_route(self):
Expand All @@ -72,7 +72,7 @@ def test_expand_route_not_found(self):
expand(route.route_for_task("a"))


class test_lookup_route(unittest.TestCase):
class test_lookup_route(Case):

def test_init_queues(self):
router = routes.Router(queues=None)
Expand Down Expand Up @@ -125,7 +125,7 @@ def test_lookup_paths_traversed(self):
dict(d_queue, queue=current_app.conf.CELERY_DEFAULT_QUEUE))


class test_prepare(unittest.TestCase):
class test_prepare(Case):

def test_prepare(self):
from celery.datastructures import LRUCache
Expand Down
4 changes: 2 additions & 2 deletions celery/tests/test_backends/__init__.py
Expand Up @@ -4,10 +4,10 @@
from celery import backends
from celery.backends.amqp import AMQPBackend
from celery.backends.cache import CacheBackend
from celery.tests.utils import unittest
from celery.tests.utils import Case


class TestBackends(unittest.TestCase):
class TestBackends(Case):

def test_get_backend_aliases(self):
expects = [("amqp", AMQPBackend),
Expand Down
5 changes: 2 additions & 3 deletions celery/tests/test_backends/test_amqp.py
Expand Up @@ -15,8 +15,7 @@
from celery.exceptions import TimeoutError
from celery.utils import uuid

from celery.tests.utils import unittest
from celery.tests.utils import sleepdeprived
from celery.tests.utils import Case, sleepdeprived


class SomeClass(object):
Expand All @@ -25,7 +24,7 @@ def __init__(self, data):
self.data = data


class test_AMQPBackend(unittest.TestCase):
class test_AMQPBackend(Case):

def create_backend(self, **opts):
opts = dict(dict(serializer="pickle", persistent=False), **opts)
Expand Down
18 changes: 9 additions & 9 deletions celery/tests/test_backends/test_base.py
Expand Up @@ -20,7 +20,7 @@
from celery.backends.base import BaseDictBackend, DisabledBackend
from celery.utils import uuid

from celery.tests.utils import unittest
from celery.tests.utils import Case


class wrapobject(object):
Expand All @@ -38,7 +38,7 @@ def __init__(self, *args, **kwargs):
b = BaseBackend()


class test_serialization(unittest.TestCase):
class test_serialization(Case):

def test_create_exception_cls(self):
self.assertTrue(serialization.create_exception_cls("FooError", "m"))
Expand All @@ -47,7 +47,7 @@ def test_create_exception_cls(self):
KeyError))


class test_BaseBackend_interface(unittest.TestCase):
class test_BaseBackend_interface(Case):

def test_get_status(self):
with self.assertRaises(NotImplementedError):
Expand Down Expand Up @@ -108,7 +108,7 @@ def test_on_chord_apply(self, unlock="celery.chord_unlock"):
tasks[unlock] = p


class test_exception_pickle(unittest.TestCase):
class test_exception_pickle(Case):

def test_oldstyle(self):
if Oldstyle is None:
Expand All @@ -127,7 +127,7 @@ def test_unpickleable(self):
self.assertIsNone(fnpe(Impossible()))


class test_prepare_exception(unittest.TestCase):
class test_prepare_exception(Case):

def test_unpickleable(self):
x = b.prepare_exception(Unpickleable(1, 2, "foo"))
Expand Down Expand Up @@ -193,7 +193,7 @@ def _delete_taskset(self, taskset_id):
self._data.pop(taskset_id, None)


class test_BaseDictBackend(unittest.TestCase):
class test_BaseDictBackend(Case):

def setUp(self):
self.b = DictBackend()
Expand Down Expand Up @@ -232,7 +232,7 @@ def test_reload_task_result(self):
self.b._cache["task-exists"] = {"result": "task"}


class test_KeyValueStoreBackend(unittest.TestCase):
class test_KeyValueStoreBackend(Case):

def setUp(self):
self.b = KVBackend()
Expand Down Expand Up @@ -277,7 +277,7 @@ def test_restore_missing_taskset(self):
self.assertIsNone(self.b.restore_taskset("xxx-nonexistant"))


class test_KeyValueStoreBackend_interface(unittest.TestCase):
class test_KeyValueStoreBackend_interface(Case):

def test_get(self):
with self.assertRaises(NotImplementedError):
Expand All @@ -303,7 +303,7 @@ def test_forget(self):
KeyValueStoreBackend().forget("a")


class test_DisabledBackend(unittest.TestCase):
class test_DisabledBackend(Case):

def test_store_result(self):
DisabledBackend().store_result()
Expand Down
8 changes: 4 additions & 4 deletions celery/tests/test_backends/test_cache.py
Expand Up @@ -17,7 +17,7 @@
from celery.utils import uuid
from celery.utils.encoding import str_to_bytes

from celery.tests.utils import unittest, mask_modules, reset_modules
from celery.tests.utils import Case, mask_modules, reset_modules


class SomeClass(object):
Expand All @@ -26,7 +26,7 @@ def __init__(self, data):
self.data = data


class test_CacheBackend(unittest.TestCase):
class test_CacheBackend(Case):

def setUp(self):
self.tb = CacheBackend(backend="memory://")
Expand Down Expand Up @@ -150,7 +150,7 @@ def mock_pylibmc(self):
sys.modules["pylibmc"] = prev


class test_get_best_memcache(unittest.TestCase, MockCacheMixin):
class test_get_best_memcache(Case, MockCacheMixin):

def test_pylibmc(self):
with self.mock_pylibmc():
Expand Down Expand Up @@ -192,7 +192,7 @@ def test_backends(self):
self.assertTrue(fun())


class test_memcache_key(unittest.TestCase, MockCacheMixin):
class test_memcache_key(Case, MockCacheMixin):

def test_memcache_unicode_key(self):
with self.mock_memcache():
Expand Down

0 comments on commit cf42285

Please sign in to comment.