Ready for Dataiku 10? Try out the Crash Course on new features!GET STARTED

pyunitt test for mock patch in dataiku

sonal_18
Level 1
pyunitt test for mock patch in dataiku

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.

0 Kudos
1 Reply
AlexT
Dataiker
Dataiker

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. 

0 Kudos
A banner prompting to get Dataiku DSS