V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
z740713651
V2EX  ›  Python

求助: celery pytest 的单元怎么写

  •  
  •   z740713651 ·
    AngusWG · 2021-05-28 15:53:34 +08:00 · 1178 次点击
    这是一个创建于 1035 天前的主题,其中的信息可能已经有所发展或是发生改变。

    找到了这个资料 也尝试了改 conftest.py 文件的

    # conftest.py
    @pytest.fixture(scope='session')
    def celery_config():
        return {
            'broker_url': 'redis://127.0.0.1:6379/0',
            'result_backend': 'redis://127.0.0.1:6379/0',
        }
    
    
    # test_file_a.py
    @pytest.mark.celery_app
    @pytest.mark.celery_worker
    @pytest.mark.asyncio
    async def test_invoice_ws(self, async_client):
    	async with async_client.websocket_connect(f"/server_a/api/v1/assets/long_query") as ws:
            await ws.send_json(query)
            ....
    

    并不起效果

    # pip list | grep celery
    celery == 5.0.0
    pytest-celery == 0.0.0
    
    # python --version
    Python 3.9.4
    

    求大佬们给个能跑的 demo 抄一下 Orz

    z740713651
        1
    z740713651  
    OP
       2021-05-28 17:58:55 +08:00
    已解决
    celery_app.conf['task_always_eager'] = True
    搞定
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1187 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 23:09 · PVG 07:09 · LAX 16:09 · JFK 19:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.