repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
celery
t/integration/test_mem_leak_in_exception_handling.py
.py
""" Integration tests for memory leak issue #8882. These tests reproduce memory leak scenarios that occur when Celery tasks raise unhandled exceptions, causing ExceptionInfo objects to not be properly garbage collected. """ import gc import logging import os import tracemalloc from celery import Celery logger = log...
262
8,807
celery
t/integration/test_tasks.py
.py
import logging import platform import time from datetime import datetime, timedelta, timezone from uuid import uuid4 import billiard as multiprocessing import pytest import celery from celery import chain, chord, group from celery.canvas import StampingVisitor from celery.signals import task_received from celery.util...
874
33,223
celery
t/integration/test_loader.py
.py
import pytest from celery import shared_task @shared_task() def dummy_task(x, y): return x + y class test_loader: def test_autodiscovery__when_packages_exist(self, manager): # Arrange expected_package_name, _, module_name = __name__.rpartition('.') unexpected_package_name = 'datetim...
39
1,352
celery
t/integration/worker_config.py
.py
# Test config for t/integration/test_worker.py broker_url = 'amqp://guest:guest@foobar:1234//' # Fail fast for test_run_worker broker_connection_retry_on_startup = False broker_connection_retry = False broker_connection_timeout = 0 worker_log_color = False worker_redirect_stdouts = False
13
293
celery
t/integration/test_inspect.py
.py
import os import re from datetime import datetime, timedelta, timezone from time import sleep from unittest.mock import ANY import pytest from celery.utils.nodenames import anon_nodename from .tasks import add, sleeping NODENAME = anon_nodename() _flaky = pytest.mark.flaky(reruns=5, reruns_delay=2) _timeout = pyte...
238
7,815
celery
t/integration/test_security.py
.py
import datetime import os import socket import tempfile import pytest from cryptography import x509 from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.x509.oid import NameO...
119
3,833
celery
t/integration/test_connection_recovery.py
.py
"""Integration tests for broker-connection recovery (GH-9705). Exercises the two fixes that prevent the worker from hanging indefinitely after a broker connection loss: 1. ``on_connection_error_after_connected()`` now closes the broken connection after calling ``collect()``, so the stale socket is released befo...
46
1,875
celery
t/integration/test_worker.py
.py
import subprocess import pytest from celery import Celery from .conftest import flaky from .tasks import add TIMEOUT = 10 def test_run_worker(): with pytest.raises(subprocess.CalledProcessError) as exc_info: subprocess.check_output( ["celery", "--config", "t.integration.worker_config", "wo...
92
2,884
celery
t/integration/tasks.py
.py
import os from collections.abc import Iterable from time import sleep from pydantic import BaseModel from celery import Signature, Task, chain, chord, group, shared_task from celery.canvas import signature from celery.exceptions import Reject, SoftTimeLimitExceeded from celery.utils.log import get_task_logger from ce...
579
15,440
celery
t/integration/test_serialization.py
.py
import os import subprocess import time from concurrent.futures import ThreadPoolExecutor disabled_error_message = "Refusing to deserialize disabled content of type " class test_config_serialization: def test_accept(self, celery_app): app = celery_app # Redefine env to use in subprocess #...
55
1,646
celery
t/integration/test_canvas.py
.py
import collections import re import tempfile import uuid from datetime import datetime, timedelta, timezone from time import monotonic, sleep import pytest from celery import chain, chord, group, signature from celery.backends.base import BaseKeyValueStoreBackend from celery.canvas import StampingVisitor from celery....
3,880
149,239
celery
t/integration/serialization_config.py
.py
event_serializer = "pickle" result_serializer = "pickle" accept_content = ["pickle", "json"] worker_redirect_stdouts = False worker_log_color = False
6
150
celery
t/integration/conftest.py
.py
import json import logging import os import re import time import pytest from celery.contrib.pytest import celery_app, celery_session_app, celery_session_worker from celery.contrib.testing.manager import Manager from celery.exceptions import TimeoutError from t.integration.tasks import get_redis_connection # we have...
151
4,376
celery
t/benchmarks/bench_worker.py
.py
import os import sys import time from celery import Celery os.environ.update( NOSETPS='yes', USE_FAST_LOCALS='yes', ) DEFAULT_ITS = 40000 BROKER_TRANSPORT = os.environ.get('BROKER', 'librabbitmq://') if hasattr(sys, 'pypy_version_info'): BROKER_TRANSPORT = 'pyamqp://' app = Celery('bench_worker') app....
111
2,816
celery
t/unit/test_generics.py
.py
import contextlib import sys import typing from typing import get_args import pytest from celery.app import Celery from celery.app.task import Context, Task from celery.canvas import Signature from celery.local import class_property from celery.result import AsyncResult from celery.utils.objects import FallbackContex...
73
3,371
celery
t/unit/test_loops.py
.py
from unittest.mock import Mock, patch import pytest from celery import bootsteps from celery.worker.loops import synloop def test_synloop_perform_pending_operations_on_system_exit(): # Mock dependencies obj = Mock() connection = Mock() consumer = Mock() blueprint = Mock() hub = Mock() qo...
58
1,581
celery
t/unit/test_canvas.py
.py
import uuid class test_Canvas: def test_freeze_reply_to(self): # Tests that Canvas.freeze() correctly # creates reply_to option @self.app.task def test_task(a, b): return s = test_task.s(2, 2) s.freeze() from concurrent.futures import ThreadP...
34
989
celery
t/unit/conftest.py
.py
import builtins import inspect import io import logging import os import platform import sys import threading import types import warnings from contextlib import contextmanager from functools import wraps from importlib import import_module, reload from unittest.mock import MagicMock, Mock, patch import pytest from ko...
788
23,215
celery
t/unit/bin/test_beat.py
.py
import pytest from click.testing import CliRunner from celery.app.log import Logging from celery.bin.celery import celery @pytest.fixture(scope='session') def use_celery_app_trap(): return False def test_cli(isolated_cli_runner: CliRunner): Logging._setup = True # To avoid hitting the logging sanity check...
35
1,116
celery
t/unit/bin/test_control.py
.py
import os import re from unittest.mock import patch import pytest from click.testing import CliRunner from kombu.exceptions import OperationalError from celery.bin.celery import celery from celery.platforms import EX_UNAVAILABLE _GLOBAL_OPTIONS = ['-A', 't.unit.bin.proj.app_with_custom_cmds', '--broker', 'memory://'...
258
9,730
celery
t/unit/bin/test_daemonization.py
.py
from __future__ import annotations from unittest.mock import patch import pytest from click.testing import CliRunner from celery.bin.celery import celery from .proj import daemon_config as config @pytest.mark.usefixtures('depends_on_current_app') @pytest.mark.parametrize("daemon", ["worker", "beat", "events"]) de...
23
722
celery
t/unit/bin/test_worker.py
.py
import os from unittest.mock import Mock, patch import pytest from click.testing import CliRunner from celery.app.log import Logging from celery.bin.celery import celery from celery.worker.consumer.tasks import Tasks @pytest.fixture(scope='session') def use_celery_app_trap(): return False @pytest.fixture def ...
128
5,116
celery
t/unit/bin/proj/pyramid_celery_app.py
.py
from unittest.mock import MagicMock, Mock from click import Option from celery import Celery # This module defines a mocked Celery application to replicate # the behavior of Pyramid-Celery's configuration by preload options. # Preload options should propagate to commands like shell and purge etc. # # The Pyramid-Cel...
54
1,519
celery
t/unit/bin/proj/app.py
.py
from celery import Celery app = Celery(set_as_current=False) app.config_from_object("t.integration.worker_config")
5
116
celery
t/unit/bin/proj/daemon_config.py
.py
# Test config for t/unit/bin/test_deamonization.py beat_pidfile = "/tmp/beat.test.pid" beat_logfile = "/tmp/beat.test.log" beat_uid = 42 beat_gid = 4242 beat_umask = 0o777 beat_executable = "/beat/bin/python" events_pidfile = "/tmp/events.test.pid" events_logfile = "/tmp/events.test.log" events_uid = 42 events_gid = ...
23
564
celery
t/unit/bin/proj/scheduler.py
.py
from celery.beat import Scheduler class mScheduler(Scheduler): def tick(self): raise Exception
7
109
celery
t/unit/bin/proj/__init__.py
.py
from celery import Celery hello = Celery(set_as_current=False)
4
64
celery
t/unit/bin/proj/app_with_custom_cmds.py
.py
from celery import Celery from celery.worker.control import control_command, inspect_command @control_command( args=[('a', int), ('b', int)], signature='a b', ) def custom_control_cmd(state, a, b): """Ask the workers to reply with a and b.""" return {'ok': f'Received {a} and {b}'} @inspect_command( ...
25
567
celery
t/unit/bin/proj/daemon.py
.py
from celery import Celery app = Celery(set_as_current=False) app.config_from_object("t.unit.bin.proj.daemon_config")
5
118
celery
t/unit/apps/test_multi.py
.py
import errno import os import signal import sys from unittest.mock import Mock, call, patch import pytest import t.skip from celery.apps.multi import Cluster, MultiParser, NamespacedOptionParser, Node, format_opt class test_functions: def test_parse_ns_range(self): m = MultiParser() assert m._p...
449
16,464
celery
t/unit/security/__init__.py
.py
""" Keys and certificates for tests (KEY1 is a private key of CERT1, etc.) Generated with `extra/security/get-cert.sh` """ KEYPASSWORD = b"samplepassword" KEY1 = """-----BEGIN RSA PRIVATE KEY----- MIICXQIBAAKBgQC9Twh0V5q/R1Q8N+Y+CNM4lj9AXeZL0gYowoK1ht2ZLCDU9vN5 dhV0x3sqaXLjQNeCGd6b2vTbFGdF2E45//IWz6/BdPFWaPm0rtYbcxZ...
138
7,344
celery
t/unit/security/test_security.py
.py
"""Keys and certificates for tests (KEY1 is a private key of CERT1, etc.) Generated with: .. code-block:: console $ openssl genrsa -des3 -passout pass:test -out key1.key 1024 $ openssl req -new -key key1.key -out key1.csr -passin pass:test $ cp key1.key key1.key.org $ openssl rsa -in key1.key.org -ou...
178
6,219
celery
t/unit/security/case.py
.py
import pytest class SecurityCase: def setup_method(self): pytest.importorskip('cryptography')
8
109
celery
t/unit/security/test_certificate.py
.py
import datetime import os from unittest.mock import Mock, patch import pytest from celery.exceptions import SecurityError from celery.security.certificate import Certificate, CertStore, FSCertStore from t.unit import conftest from . import CERT1, CERT2, CERT_ECDSA, KEY1 from .case import SecurityCase class test_Ce...
110
3,377
celery
t/unit/security/test_serialization.py
.py
import base64 import os import pytest from kombu.serialization import registry from kombu.utils.encoding import bytes_to_str from celery.exceptions import SecurityError from celery.security.certificate import Certificate, CertStore from celery.security.key import PrivateKey from celery.security.serialization import D...
72
2,520
celery
t/unit/security/test_key.py
.py
import pytest from kombu.utils.encoding import ensure_bytes from celery.exceptions import SecurityError from celery.security.key import PrivateKey from celery.security.utils import get_digest_algorithm from . import CERT1, ENCKEY1, ENCKEY2, KEY1, KEY2, KEY_ECDSA, KEYPASSWORD from .case import SecurityCase class tes...
46
1,570
celery
t/unit/tasks/test_result.py
.py
import copy import datetime import platform import traceback from contextlib import contextmanager from unittest.mock import Mock, call, patch import pytest from celery import states, uuid from celery.app.task import Context from celery.backends.base import Backend, SyncBackendMixin from celery.exceptions import Impr...
1,091
37,572
celery
t/unit/tasks/test_tasks.py
.py
import socket import tempfile from datetime import datetime, timedelta from unittest.mock import ANY, MagicMock, Mock, patch, sentinel import pytest from kombu import Queue from kombu.exceptions import EncodeError from celery import Task, chain, group, uuid from celery.app.task import _reprtask from celery.canvas imp...
1,835
68,624
celery
t/unit/tasks/unit_tasks.py
.py
from celery import shared_task @shared_task def mul(x, y): return x * y
7
78
celery
t/unit/tasks/test_chord.py
.py
from contextlib import contextmanager from unittest.mock import Mock, PropertyMock, patch, sentinel import pytest from celery import canvas, group, result, uuid from celery.canvas import Signature from celery.exceptions import ChordError, Retry from celery.result import AsyncResult, EagerResult, GroupResult def pas...
392
12,308
celery
t/unit/tasks/test_states.py
.py
import pytest from celery import states class test_state_precedence: @pytest.mark.parametrize('r,l', [ (states.SUCCESS, states.PENDING), (states.FAILURE, states.RECEIVED), (states.REVOKED, states.STARTED), (states.SUCCESS, 'CRASHED'), (states.FAILURE, 'CRASHED'), ]) ...
40
1,085
celery
t/unit/tasks/test_trace.py
.py
from unittest.mock import ANY, Mock, PropertyMock, patch from uuid import uuid4 import pytest from billiard.einfo import ExceptionInfo from kombu.exceptions import EncodeError from celery import group, signals, states, uuid from celery.app.task import Context from celery.app.trace import (TraceInfo, build_tracer, fas...
1,272
45,360
celery
t/unit/tasks/test_stamping.py
.py
import math import uuid from collections.abc import Iterable import pytest from celery import Task from celery.canvas import Signature, StampingVisitor, _chain, _chord, chain, chord, group, signature from celery.exceptions import Ignore class LinkingVisitor(StampingVisitor): def on_signature(self, actual_sig: S...
1,316
55,272
celery
t/unit/tasks/test_context.py
.py
from celery.app.task import Context # Retrieve the values of all context attributes as a # dictionary in an implementation-agnostic manner. def get_context_as_dict(ctx, getter=getattr): defaults = {} for attr_name in dir(ctx): if attr_name.startswith('_'): continue # Ignore pseudo-privat...
143
5,505
celery
t/unit/tasks/test_canvas.py
.py
import json import math from collections.abc import Iterable from unittest.mock import ANY, MagicMock, Mock, call, patch, sentinel import pytest from celery import states from celery._state import _task_stack from celery.canvas import (Signature, _chain, _maybe_group, _merge_dictionaries, chain, chord, chunks, group,...
2,269
87,165
celery
t/unit/events/test_snapshot.py
.py
from unittest.mock import Mock, patch import pytest from celery.app.events import Events from celery.events.snapshot import Polaroid, evcam class MockTimer: installed = [] def call_repeatedly(self, secs, fun, *args, **kwargs): self.installed.append(fun) return Mock(name='TRef') timer = Mo...
122
3,359
celery
t/unit/events/test_events.py
.py
import socket from unittest.mock import Mock, call import pytest from celery.events import Event from celery.events.receiver import CLIENT_CLOCK_SKEW from celery.exceptions import ImproperlyConfigured class MockProducer: raise_on_publish = False def __init__(self, *args, **kwargs): self.sent = [] ...
582
20,810
celery
t/unit/events/test_cursesmon.py
.py
import pytest pytest.importorskip('curses') class MockWindow: def getmaxyx(self): return self.y, self.x class test_CursesDisplay: def setup_method(self): from celery.events import cursesmon self.monitor = cursesmon.CursesMonitor(object(), app=self.app) self.win = MockWindo...
63
2,304
celery
t/unit/events/test_dumper.py
.py
import io from datetime import datetime, timezone from celery.events import dumper def test_humanize_type(): assert dumper.humanize_type('worker-online') == 'started' assert dumper.humanize_type('worker-offline') == 'shutdown' assert dumper.humanize_type('worker-heartbeat') == 'heartbeat' def test_dump...
71
2,042
celery
t/unit/events/test_state.py
.py
import pickle from decimal import Decimal from itertools import count from random import shuffle from time import time from unittest.mock import Mock, patch import pytest from celery import states, uuid from celery.events import Event from celery.events.state import HEARTBEAT_DRIFT_MAX, HEARTBEAT_EXPIRE_WINDOW, State...
700
22,261
celery
t/unit/fixups/test_django.py
.py
from contextlib import contextmanager from unittest.mock import MagicMock, Mock, patch import pytest from celery.concurrency.thread import TaskPool as ThreadTaskPool from celery.fixups.django import DjangoFixup, DjangoWorkerFixup, FixupWarning, _maybe_close_fd, fixup from t.unit import conftest class FixupCase: ...
496
19,447
celery
t/unit/backends/test_database.py
.py
import os from datetime import datetime from pickle import dumps, loads from unittest.mock import Mock, patch import pytest from celery import states, uuid from celery.app.task import Context from celery.exceptions import ImproperlyConfigured pytest.importorskip('sqlalchemy') from celery.backends.database import Da...
1,015
37,138
celery
t/unit/backends/test_arangodb.py
.py
"""Tests for the ArangoDb.""" import datetime from unittest.mock import MagicMock, Mock, patch, sentinel import pytest from celery.app import backends from celery.backends import arangodb as module from celery.backends.arangodb import ArangoDbBackend from celery.exceptions import ImproperlyConfigured try: import...
229
8,246
celery
t/unit/backends/test_dynamodb.py
.py
from decimal import Decimal from unittest.mock import ANY, MagicMock, Mock, call, patch, sentinel import pytest from celery import states, uuid from celery.backends import dynamodb as module from celery.backends.dynamodb import DynamoDBBackend from celery.exceptions import ImproperlyConfigured pytest.importorskip('b...
634
22,638
celery
t/unit/backends/test_asynchronous.py
.py
import logging import os import socket import sys import threading import time from unittest.mock import Mock, patch import pytest from vine import promise from celery.backends.asynchronous import E_CELERY_RESTART_REQUIRED, BaseResultConsumer, greenletDrainer from celery.backends.base import Backend from celery.utils...
714
23,574
celery
t/unit/backends/test_mongodb.py
.py
import datetime from pickle import dumps, loads from unittest.mock import ANY, MagicMock, Mock, patch, sentinel import dns.version import pymongo import pytest from kombu.exceptions import EncodeError try: from pymongo.errors import ConfigurationError except ImportError: ConfigurationError = None import sys...
800
31,690
celery
t/unit/backends/test_elasticsearch.py
.py
from datetime import datetime, timezone from unittest.mock import Mock, call, patch, sentinel import pytest from billiard.einfo import ExceptionInfo from kombu.utils.encoding import bytes_to_str from celery import states try: from elasticsearch import exceptions except ImportError: exceptions = None try: ...
973
37,359
celery
t/unit/backends/test_cosmosdbsql.py
.py
from unittest.mock import Mock, call, patch import pytest from celery import states from celery.backends import cosmosdbsql from celery.backends.cosmosdbsql import CosmosDBSQLBackend from celery.exceptions import ImproperlyConfigured MODULE_TO_MOCK = "celery.backends.cosmosdbsql" pytest.importorskip('pydocumentdb')...
140
4,994
celery
t/unit/backends/test_cassandra.py
.py
from datetime import datetime from pickle import dumps, loads from unittest.mock import Mock import pytest from celery import states from celery.exceptions import ImproperlyConfigured from celery.utils.objects import Bunch CASSANDRA_MODULES = [ 'cassandra', 'cassandra.auth', 'cassandra.cluster', 'cas...
279
8,944
celery
t/unit/backends/test_consul.py
.py
from unittest.mock import Mock import pytest from celery.backends.consul import ConsulBackend pytest.importorskip('consul') class test_ConsulBackend: def setup_method(self): self.backend = ConsulBackend( app=self.app, url='consul://localhost:800') def test_supports_autoexpire(self): ...
44
1,448
celery
t/unit/backends/test_filesystem.py
.py
import os import pickle import sys import tempfile import time from unittest.mock import patch import pytest import t.skip from celery import states, uuid from celery.backends import filesystem from celery.backends.filesystem import FilesystemBackend from celery.exceptions import ImproperlyConfigured @t.skip.if_win...
131
4,435
celery
t/unit/backends/test_azureblockblob.py
.py
from unittest.mock import Mock, call, patch import pytest from celery import states from celery.backends import azureblockblob from celery.backends.azureblockblob import AzureBlockBlobBackend from celery.exceptions import ImproperlyConfigured MODULE_TO_MOCK = "celery.backends.azureblockblob" pytest.importorskip('az...
229
8,718
celery
t/unit/backends/test_s3.py
.py
from unittest.mock import patch import boto3 import pytest from botocore.exceptions import ClientError try: from moto import mock_aws except ImportError: from moto import mock_s3 as mock_aws from celery import states from celery.backends.s3 import S3Backend from celery.exceptions import ImproperlyConfigured ...
187
6,731
celery
t/unit/backends/test_base.py
.py
import copy import re from contextlib import contextmanager from unittest.mock import ANY, MagicMock, Mock, call, patch, sentinel from uuid import UUID import pytest from kombu.serialization import prepare_accept_content from kombu.utils.encoding import bytes_to_str, ensure_bytes import celery from celery import chor...
1,840
69,164
celery
t/unit/backends/test_redis.py
.py
import itertools import json import random import ssl from contextlib import contextmanager from datetime import timedelta from pickle import dumps, loads from unittest.mock import ANY, Mock, call, patch import pytest try: from redis import CredentialProvider, exceptions except ImportError: exceptions = None ...
1,872
73,315
celery
t/unit/backends/test_couchbase.py
.py
"""Tests for the CouchbaseBackend.""" from datetime import timedelta from unittest.mock import MagicMock, Mock, patch, sentinel import pytest from celery import states from celery.app import backends from celery.backends import couchbase as module from celery.backends.couchbase import CouchbaseBackend from celery.exc...
139
4,846
celery
t/unit/backends/test_gcs.py
.py
from datetime import datetime, timedelta, timezone from unittest.mock import MagicMock, Mock, call, patch import pytest from google.cloud.exceptions import NotFound from celery.backends.gcs import GCSBackend from celery.exceptions import ImproperlyConfigured class test_GCSBackend: def setup_method(self): ...
590
22,310
celery
t/unit/backends/test_couchdb.py
.py
from unittest.mock import MagicMock, Mock, sentinel from urllib.parse import urlparse import pytest from kombu.utils.encoding import str_to_bytes from celery import states, uuid from celery.app import backends from celery.backends import couchdb as module from celery.backends.couchdb import CouchBackend from celery.e...
214
7,606
celery
t/unit/backends/test_rpc.py
.py
import socket import uuid from unittest.mock import Mock, patch import pytest from celery import chord, group, states from celery._state import _task_stack from celery.app.task import Context from celery.backends.rpc import RPCBackend class test_RPCResultConsumer: def get_backend(self): return RPCBacken...
496
20,109
celery
t/unit/backends/test_cache.py
.py
import sys import types from contextlib import contextmanager from unittest.mock import Mock, patch import pytest from kombu.utils.encoding import ensure_bytes, str_to_bytes from celery import signature, states, uuid from celery.backends.cache import CacheBackend, DummyClient, backends from celery.exceptions import I...
285
10,318
celery
t/unit/utils/test_imports.py
.py
import os import platform import sys from unittest.mock import Mock, patch import pytest from celery.utils.imports import (NotAPackage, cwd_in_path, find_module, gen_task_name, module_file, qualname, reload_from_cwd) def test_find_module(): def imp_side_effect(module): ...
124
4,064
celery
t/unit/utils/test_iso8601.py
.py
from datetime import datetime, timedelta, timezone import pytest from celery.exceptions import CPendingDeprecationWarning from celery.utils.iso8601 import parse_iso8601 def test_parse_iso8601_utc(): dt = parse_iso8601("2023-10-26T10:30:00Z") assert dt == datetime(2023, 10, 26, 10, 30, 0, tzinfo=timezone.utc...
77
2,883
celery
t/unit/utils/test_deprecated.py
.py
from unittest.mock import patch import pytest from celery.utils import deprecated class test_deprecated_property: @patch('celery.utils.deprecated.warn') def test_deprecated(self, warn): class X: _foo = None @deprecated.Property(deprecation='1.2') def foo(self):...
69
1,739
celery
t/unit/utils/test_graph.py
.py
from unittest.mock import Mock from celery.utils.graph import DependencyGraph from celery.utils.text import WhateverIO class test_DependencyGraph: def graph1(self): res_a = self.app.AsyncResult('A') res_b = self.app.AsyncResult('B') res_c = self.app.GroupResult('C', [res_a]) res_...
71
1,935
celery
t/unit/utils/test_debug.py
.py
from unittest.mock import Mock import pytest from celery.utils import debug def test_on_blocking(patching): getframeinfo = patching('inspect.getframeinfo') frame = Mock(name='frame') with pytest.raises(RuntimeError): debug._on_blocking(1, frame) getframeinfo.assert_called_with(frame) d...
87
2,357
celery
t/unit/utils/test_local.py
.py
import sys from importlib.util import find_spec from unittest.mock import Mock import pytest from celery.local import PromiseProxy, Proxy, maybe_evaluate, try_import class test_try_import: def test_imports(self): assert try_import(__name__) def test_when_default(self): default = object() ...
356
8,515
celery
t/unit/utils/test_timer2.py
.py
import sys import time from unittest.mock import Mock, call, patch from celery.utils import timer2 as timer2 class test_Timer: def test_enter_after(self): t = timer2.Timer() try: done = [False] def set_done(): done[0] = True t.call_after(0.3,...
106
3,215
celery
t/unit/utils/test_collections.py
.py
import pickle from collections.abc import Mapping from itertools import count from time import monotonic from unittest.mock import Mock import pytest from billiard.einfo import ExceptionInfo import t.skip from celery.utils.collections import (AttributeDict, BufferMap, ChainMap, ConfigurationView, DictAttribute, ...
461
13,057
celery
t/unit/utils/test_dispatcher.py
.py
import gc import sys import time from celery.utils.dispatch import Signal if sys.platform.startswith('java'): def garbage_collect(): # Some JVM GCs will execute finalizers in a different thread, meaning # we need to wait for that to complete before we go on looking for the # effects of th...
198
5,667
celery
t/unit/utils/test_nodenames.py
.py
from kombu import Queue from celery.utils.nodenames import worker_direct class test_worker_direct: def test_returns_if_queue(self): q = Queue('foo') assert worker_direct(q) is q
11
202
celery
t/unit/utils/test_saferepr.py
.py
import ast import re import struct from decimal import Decimal from pprint import pprint import pytest from celery.utils.saferepr import saferepr D_NUMBERS = { b'integer': 1, b'float': 1.3, b'decimal': Decimal('1.3'), b'long': 4, b'complex': complex(13.3), } D_INT_KEYS = {v: k for k, v in D_NUMBE...
213
5,555
celery
t/unit/utils/test_functional.py
.py
import collections import sys import pytest from kombu.utils.functional import lazy from celery.utils.functional import (DummyContext, first, firstmethod, fun_accepts_kwargs, fun_takes_argument, head_from_fun, is_numeric_value, lookahead, maybe_list, mlazy, padlist, regen, ...
550
16,212
celery
t/unit/utils/test_term.py
.py
import os from base64 import b64encode from tempfile import NamedTemporaryFile from unittest.mock import patch import pytest import t.skip from celery.utils import term from celery.utils.term import _read_as_base64, colored, fg, supports_images @t.skip.if_win32 class test_colored: @pytest.fixture(autouse=True)...
88
2,854
celery
t/unit/utils/test_sysinfo.py
.py
import importlib import os import pytest from celery.utils.sysinfo import df, load_average try: posix = importlib.import_module('posix') except Exception: posix = None @pytest.mark.skipif( not hasattr(os, 'getloadavg'), reason='Function os.getloadavg is not defined' ) def test_load_average(patching...
36
751
celery
t/unit/utils/test_pickle.py
.py
from celery.utils.serialization import pickle class RegularException(Exception): pass class ArgOverrideException(Exception): def __init__(self, message, status_code=10): self.status_code = status_code super().__init__(message, status_code) class test_Pickle: def test_pickle_regular_e...
48
1,386
celery
t/unit/utils/test_platforms.py
.py
import errno import os import re import signal import sys import tempfile from unittest.mock import Mock, call, patch import pytest import t.skip from celery import _find_option_with_arg, platforms from celery.exceptions import SecurityError, SecurityWarning from celery.platforms import (ASSUMING_ROOT, ROOT_DISALLOWE...
1,060
33,363
celery
t/unit/utils/test_objects.py
.py
from celery.utils.objects import Bunch class test_Bunch: def test(self): x = Bunch(foo='foo', bar=2) assert x.foo == 'foo' assert x.bar == 2
10
172
celery
t/unit/utils/test_threads.py
.py
from unittest.mock import patch import pytest from celery.utils.threads import Local, LocalManager, _FastLocalStack, _LocalStack, bgThread from t.unit import conftest class test_bgThread: def test_crash(self): class T(bgThread): def body(self): raise KeyError() wi...
104
2,427
celery
t/unit/utils/test_serialization.py
.py
import json import pickle import sys from datetime import date, datetime, time, timedelta, timezone from unittest.mock import Mock import pytest from kombu import Queue from celery.utils.serialization import (STRTOBOOL_DEFAULT_TABLE, UnpickleableExceptionWrapper, ensure_serializable, ...
117
3,256
celery
t/unit/utils/test_annotations.py
.py
import inspect import sys import typing import pytest from pydantic import BaseModel from celery.utils.annotations import annotation_issubclass, get_optional_arg, is_none_type @pytest.mark.parametrize( 'value,expected', ((3, False), ('x', False), (int, False), (type(None), True)), ) def test_is_none_type(va...
97
4,101
celery
t/unit/utils/test_utils.py
.py
import pytest from celery.utils import cached_property, chunks @pytest.mark.parametrize('items,n,expected', [ (range(11), 2, [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10]]), (range(11), 3, [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10]]), (range(10), 2, [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]), ]) def test_c...
25
624
celery
t/unit/utils/test_text.py
.py
import pytest from celery.utils.text import abbr, abbrtask, ensure_newlines, indent, pretty, truncate RANDTEXT = """\ The quick brown fox jumps over the lazy dog\ """ RANDTEXT_RES = """\ The quick brown fox jumps over the lazy dog\ """ QUEUES = { 'queue1': { 'exchange': 'exchange1', ...
82
1,935
celery
t/unit/utils/test_time.py
.py
import sys from datetime import datetime, timedelta from datetime import timezone as _timezone from datetime import tzinfo from unittest.mock import Mock, patch import pytest if sys.version_info >= (3, 9): from zoneinfo import ZoneInfo else: from backports.zoneinfo import ZoneInfo from celery.utils.iso8601 i...
422
14,467
celery
t/unit/concurrency/test_concurrency.py
.py
import importlib import os import sys from itertools import count from unittest.mock import Mock, patch import pytest from celery import concurrency from celery.concurrency.base import BasePool, apply_target from celery.exceptions import WorkerShutdown, WorkerTerminate class test_BasePool: def test_apply_targe...
189
5,687
celery
t/unit/concurrency/test_gevent.py
.py
from unittest.mock import Mock from celery.concurrency.gevent import TaskPool, Timer, apply_timeout gevent_modules = ( 'gevent', 'gevent.greenlet', 'gevent.monkey', 'gevent.pool', 'gevent.signal', ) class test_gevent_patch: def test_is_patched(self): self.patching.modules(*gevent_mo...
152
4,170
celery
t/unit/concurrency/test_pool.py
.py
import itertools import time import pytest from billiard.einfo import ExceptionInfo pytest.importorskip('multiprocessing') def do_something(i): return i * i def long_something(): time.sleep(1) def raise_something(i): try: raise KeyError('FOO EXCEPTION') except KeyError: return Ex...
73
1,837
celery
t/unit/concurrency/test_eventlet.py
.py
import sys from unittest.mock import Mock, patch import pytest pytest.importorskip('eventlet') from greenlet import GreenletExit # noqa import t.skip # noqa from celery.concurrency.eventlet import TaskPool, Timer, apply_target # noqa eventlet_modules = ( 'eventlet', 'eventlet.debug', 'eventlet.green...
166
4,721
celery
t/unit/concurrency/test_solo.py
.py
import operator from unittest.mock import Mock from celery import signals from celery.concurrency import solo from celery.utils.functional import noop class test_solo_TaskPool: def test_on_start(self): x = solo.TaskPool() x.on_start() def test_on_apply(self): x = solo.TaskPool() ...
32
848
celery
t/unit/concurrency/test_prefork.py
.py
import errno import os import socket import tempfile from itertools import cycle from unittest.mock import MagicMock, Mock, patch import pytest from billiard.pool import ApplyResult from kombu.asynchronous import Hub import t.skip from celery.app.defaults import DEFAULTS from celery.concurrency.asynpool import iterat...
1,117
39,245
celery
t/unit/concurrency/test_thread.py
.py
import operator import time import pytest from celery.utils.functional import noop class test_thread_TaskPool: def test_on_apply(self): from celery.concurrency import thread x = thread.TaskPool() try: x.on_apply(operator.add, (2, 2), {}, noop, noop) finally: ...
86
2,678