fix: tolerates mix of testing commands

This commit is contained in:
Jovial Joe Jayarson 2020-10-19 13:34:10 +05:30
parent 0e61c1620f
commit 25316e4f7f

View File

@ -4,6 +4,12 @@ Tests for the main.py
import unittest
import os
try:
# For travis build which uses
# python -m unittest discover
from main import make_graph
except Exception as e:
print("Error: missing 'main.py'\nTrying ablsolute import...")
class TestMain(unittest.TestCase):
@ -49,9 +55,12 @@ if __name__ == '__main__':
if __package__ is None:
import sys
# because test_main.py is one level below main.py
# python test/test_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
else:
# Later on if WakaReadme is implemetaion as package
# python -m tests/test_main
from ..main import make_graph
unittest.main()