Aug-22-2020, 01:51 PM
(This post was last modified: Aug-22-2020, 01:51 PM by sandro4912.)
I'm totally confused about project organization.
I organized my project with a structure like this:
Now in the main.py i import like this:
I already could run unittests with pytest. In the unit tests in the test folder I also import relative like this:
I organized my project with a structure like this:
bricks
--source
--game_objects
--types
+ level.py
+ main.py
--tests
--game_objects
--typesEach of these folders and subfolders contains a __init__.py.Now in the main.py i import like this:
from bricks.source.level import Level from bricks.source.level import read_level_from_json_fileThen I call a function like this:
def main():
level = read_level_from_json_file("../level/1.json")
print(level)
if __name__ == "__main__":
main()From the root folder bricks I tried to call the main.py like this but i get import errors:(virtual) sandro@sandropc:~/Documents/Bricks_py/bricks$ python3 source/main.py
Traceback (most recent call last):
File "source/main.py", line 1, in <module>
from bricks.source.level import Level
ModuleNotFoundError: No module named 'bricks'
(virtual) sandro@sandropc:~/Documents/Bricks_py/bricks$ What can I do here to fix this?I already could run unittests with pytest. In the unit tests in the test folder I also import relative like this:
from bricks.source.game_objects.ball import Ball from bricks.source.types.point import Point from bricks.source.types.angle import Angle
