From 0e61c1620fcf09ab4269c4debed18b5f820bc137 Mon Sep 17 00:00:00 2001 From: Jovial Joe Jayarson Date: Mon, 19 Oct 2020 12:55:47 +0530 Subject: [PATCH] fix: fixes import path - Import main from absolute if relative path is not available - Ignored .vscode/ configs --- .gitignore | 5 ++++- tests/test_main.py | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 054c7e1..15a70ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ #generated when running the tests -__pycache__/ \ No newline at end of file +__pycache__/ + +# Local VS code configurations +.vscode/ \ No newline at end of file diff --git a/tests/test_main.py b/tests/test_main.py index 4246763..90ca4b9 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,7 +1,6 @@ ''' Tests for the main.py ''' -from main import make_graph import unittest import os @@ -47,4 +46,12 @@ class TestMain(unittest.TestCase): if __name__ == '__main__': + if __package__ is None: + import sys + # because test_main.py is one level below main.py + sys.path.append(os.path.dirname( + os.path.dirname(os.path.abspath(__file__)))) + from main import make_graph + else: # Later on if WakaReadme is implemetaion as package + from ..main import make_graph unittest.main()