I’m developing a simple application in python which can be summarized in these files:
- root_dir
- myLib (contains some modules in python)
- libraryUnderTest (contains some modules in python that import some modules from myLib directory
- TEST (contains the unittest program)
in particular, let’s assume that my test_program.py is :
import sys
import os
import unittest
from unittest import mock
from unittest.mock import patch
import socket
lib_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
sys.path.append(lib_path)
import libUnderTest as lut
class TestExample(unittest.TestCase):
def test_1(self):
"""
Simple Test
"""
tmp = lut.myObject(100, "int32", "pathToFile")
self.assertEqual(tmp.memSize, 100)
self.assertEqual(tmp.dtype, 4)
self.assertEqual(tmp.pathToFile, "pathToFile")
self.assertEqual(tmp.logged, False)enter code here
And my program in libraryUnderTest/libUnderTest.py
import sys
sys.path.append("../myLib")
import helperLib as helpLib
'''
This class represents a memRegion as it is in the XML conf tag
'''
class GpuSatMemRegion:
def __init__(self, memSize, type, defValue, pathToFile = None):
self.memReg = helpLib.anotherObject(memSize, type)
self.memSize
self.type = type
self.defValue=defValue
self.pathToFile = pathToFile
self.logged = False
Why is my test_program failing with this message?
File “C:UsersBenelliDesktopSVNGPUatSAT-SVNtrunkswGpuOnServerlibraryUnderTest libUnderTest.py”, line 3, in
import helperLib as helpLib
ModuleNotFoundError: No module named ‘helperLib ‘
How can I avoid this inconvenience?