0

I have the following python file flow.py

from viewflow.flow import flow_job
from celery import shared_task

@shared_task
@flow_job
def populate_proxmox_info(activation):
    ...

In unit test I would like to mock this populate_proxmox_info method. Based on this answer, I tried to mock like this:

from flow import flow_job

class TestCase1(TestCase):

    @patch.object(flow_job, 'populate_proxmox_info')
    def test_auto_change(self, *args):
        ...

But it complains AttributeError: <function flow_job at 0x1121ce840> does not have the attribute 'populate_proxmox_info'

Also tried

@patch('viewflow.flow.flow_job.populate_proxmox_info') 
# and
@patch('flows.flow_job.populate_proxmox_info')

gets the same error

James Lin
  • 25,028
  • 36
  • 133
  • 233

0 Answers0