pyunitt test for mock patch in dataiku

sonal_18
sonal_18 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered, Frontrunner 2022 Participant Posts: 12 ✭✭✭✭
edited July 16 in General Discussion

Hi Team,

I'm trying to use pyunitt test with mock patch. I have placed my code in dataiku libraries.

When im calling this code with scenario it is giving error " ImportError : No module named mock"

here is my import :

import unittest
from unittest import TestCase, main, mock

Need help in how to use mock.

Answers

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,215 Dataiker
    edited July 17

    Hi,

    Can you confirm if you are using Python2 or Python3? unittest is buil-in package.

    However you may need to add mock to the "Packages to Install" list of the code env. Then use :

    Steps to do so are discussed in this thread . Once you are sure mock is installed you can import like :

    In Python 3:

    import unittest.mock

    in Python2 :

    import mock

    Let us know if that works for you.

Setup Info
    Tags
      Help me…