I am aware that this question has been asked before and I am trying one of the previously answered questions but it is still not working. I want to go through the route of converting the directories into packages but it doesn't seem to be working.
I need to import the RecipeManager class from the recipeProject.py file into my testExportRecipes.py file. I wanted to have a clean folder structure by keeping all the test files in their own folder.
The commented block of code at the start is a solution that works but I prefer the other way and want to learn why it's not working in my case.
The last thing I tried was running the file from the parent directory of my project file according to the solution over here
testExportRecipes.py
# import os, sys
# CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
# sys.path.append(os.path.dirname(CURRENT_DIR))
import unittest
from NewProjectJustDropped.recipePackage.recipeProject import RecipeManager
class TestRecipeManagement(unittest.TestCase):
def test_exported_JSON_file(self):
rm = RecipeManager()
Snippet of recipeProject.py
import json
import os
class RecipeManager:
def __init__(self):
self.data = [
{
"id": 0,
"recipeName": "McBurger",
"recipeAuthor": "Sam",
"prepTime": 10,
"cookTime": 12,
"servingSize": 1,
"ingredients": [
{"ingredientName": "bun", "quantity": 1, "measurement": "unit"},
{"ingredientName": "secretPatty",
"quantity": 1, "measurement": "unit"},
{"ingredientName": "specialMayo",
"quantity": 10, "measurement": "grams"},
{"ingredientName": "specialSauce",
"quantity": 20, "measurement": "grams"},
{"ingredientName": "lettuce",
"quantity": 8, "measurement": "grams"},
{"ingredientName": "tomato",
"quantity": 8, "measurement": "grams"}
],
"instructions": {
"1": "Assemble the bun and the secret patty.",
"2": "Spread special mayo and special sauce on the bun.",
"3": "Add lettuce and tomato on top.",
"4": "Cook the assembled burger for 12 minutes."
}
}
]
def viewRecipe(self):
# this method should print all recipes to the screen.
pass