That is my project/source directory. I am using unittest and trying to run these tests from bash: 'python -m unittest'. I have tried many different things from using os and adding it to syspath and different similar approaches, also tried many different options of importing itself like 'from algorithms import BubbleSort', or 'from algorithms.BubbleSort import BubbleSort'. Saw this for example but it didn't help either.
# inside MergeSort file
class MergeSort:
def sort_asc(self, list):
return sorted_list
# inside BubbleSort file
class BubbleSort:
def sort_asc(self, list):
return sorted_list
# inside test_main
import unittest
from algorithms.MergeSort import MergeSort
from algorithms.BubbleSort import BubbleSort
from utility.Utils import Utils
class test_algorithms(unittest.TestCase):
# and here are all my test functions
def test_bubble_asc_empty(self):
numbers = []
self.assertListEqual(BubbleSort().sort_asc(numbers), [])
Files BubbleSort and MergeSort both contain 1 class called same as the filename. Inside the application view files from eg. controllers directory can normally access algorithms directory files by importing algorithms.BubbleSort but this test_main.py just can't do same thing for some reason and all my attempts end up having either this 'is not defined error', 'module object is not callable error' or 'failed to import module error'. What am I doing wrong here?