-1

My question is when I am in the test_func1.py how to import func1.py

├───core
     - func1.py 
├───tests
     - test_func1.py 

Ayman
  • 1
  • 1
  • 3

1 Answers1

0

One solution is sys.path:

import sys
from pathlib import Path
sys.path.append(str(Path(__file__).parent.resolve().parent/'core'))
import func1
Waket Zheng
  • 3,548
  • 1
  • 14
  • 26
  • Okay , I want to ask you a question , is this the best way to build projects with testing folders , what do you think the folders of the project must look like? – Ayman May 04 '22 at 11:55
  • @Ayman Take a look at this: https://github.com/waketzheng/fastapi-tortoise-pytest-demo – Waket Zheng May 15 '22 at 12:46