fix: fixes import path

- Import main from absolute if relative path is not available
- Ignored .vscode/ configs
This commit is contained in:
Jovial Joe Jayarson 2020-10-19 12:55:47 +05:30
parent 8c16fb865f
commit 0e61c1620f
2 changed files with 12 additions and 2 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
#generated when running the tests
__pycache__/
# Local VS code configurations
.vscode/

View File

@ -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()