My folder structure is (using Pycharm),
project
-testclass.py
-__test__.py
i am trying to call the test class method from test.py. But getting below exception
from .testclass import Scheduler
ImportError: attempted relative import with no known parent package
test.py:
import asyncio
import sys
from .testclass import Scheduler
async def main():
print("main")
scheduler = Scheduler()
scheduler.run()
if __name__ == "__test__":
main()
try:
sys.exit(asyncio.run(main()))
except:
print("application exception")
testclass.py:
class Scheduler:
def __init__(self):
print("init")
async def run(self):
print("run")
How to resolve the correct import & it says relative import! How do i get this working in pycharm.
Edit: folder structure now changed as below as suggested.
project_folder
testpack (->python package)
- __init__.py
- testclass.py
-__init__.py
-__test__.py