Browse Source

Fix hard coded absolute path in tests

pull/241/merge
chriskiehl 7 years ago
parent
commit
8f91e53469
1 changed files with 17 additions and 11 deletions
  1. 28
      gooey/tests/test_integration.py

28
gooey/tests/test_integration.py

@ -1,10 +1,15 @@
import json import json
import sys
import time import time
import unittest import unittest
from concurrent import futures from concurrent import futures
from os import path
from gooey.gui import application from gooey.gui import application
from gooey.gui.lang.i18n import _ from gooey.gui.lang.i18n import _
from gooey.gui.util.freeze import getResourcePath
from gooey.gui.util.quoting import quote
class TestGooeyIntegration(unittest.TestCase): class TestGooeyIntegration(unittest.TestCase):
""" """
@ -14,7 +19,7 @@ class TestGooeyIntegration(unittest.TestCase):
running through the system, we have to execute the actual assertions in a running through the system, we have to execute the actual assertions in a
different thread different thread
""" """
LOCAL_DIR = path.dirname(__file__)
def performTest(self, configPath, assertionFunction): def performTest(self, configPath, assertionFunction):
""" """
@ -25,12 +30,13 @@ class TestGooeyIntegration(unittest.TestCase):
""" """
with open(configPath, 'r') as f: with open(configPath, 'r') as f:
build_spec = json.loads(f.read()) build_spec = json.loads(f.read())
# swaps the absolute path stored by Gooey at write time
try: # for a relative one based on our current test location
assert 0 target_pyfile = path.split(build_spec['target'].replace('"', ''))[-1]
except AssertionError as e: file_path = path.join(path.dirname(__file__), target_pyfile)
print('wtf') run_cmd = '{} -u {}'.format(quote(sys.executable), quote(file_path))
print(e) build_spec['language_dir'] = getResourcePath('languages')
build_spec['target'] = run_cmd
app = application.build_app(build_spec=build_spec) app = application.build_app(build_spec=build_spec)
executor = futures.ThreadPoolExecutor(max_workers=1) executor = futures.ThreadPoolExecutor(max_workers=1)
@ -44,21 +50,21 @@ class TestGooeyIntegration(unittest.TestCase):
def test_gooeyNormalRun(self): def test_gooeyNormalRun(self):
""" Tests the happy path through the default run mode of Gooey """ """ Tests the happy path through the default run mode of Gooey """
self.performTest('./gooey/tests/gooey_config__normal.json', self.gooeySanityTest) self.performTest(path.join(self.LOCAL_DIR, 'gooey_config__normal.json'), self.gooeySanityTest)
def test_gooeySubparserMode(self): def test_gooeySubparserMode(self):
""" Tests the happy path through the subparser run mode of Gooey """ """ Tests the happy path through the subparser run mode of Gooey """
self.performTest('./gooey/tests/gooey_config__subparser.json', self.gooeySanityTest) self.performTest(path.join(self.LOCAL_DIR, 'gooey_config__subparser.json'), self.gooeySanityTest)
def test__gooeyAutoStart(self): def test__gooeyAutoStart(self):
"""Verifies that issue #201 doesn't regress and auto_start skips the config """Verifies that issue #201 doesn't regress and auto_start skips the config
screen and hops right into the client's program""" screen and hops right into the client's program"""
self.performTest('./gooey/tests/gooey_config__autostart.json', self.verifyAutoStart) self.performTest(path.join(self.LOCAL_DIR, 'gooey_config__autostart.json'), self.verifyAutoStart)
def test__gooeyValidation(self): def test__gooeyValidation(self):
"""Verifies that custom validation routines supplied via gooey_options prevents """Verifies that custom validation routines supplied via gooey_options prevents
the user from advancing past the configuration page when they fail""" the user from advancing past the configuration page when they fail"""
self.performTest('./gooey/tests/gooey_config__autostart.json', self.verifyValidators) self.performTest(path.join(self.LOCAL_DIR, 'gooey_config__autostart.json'), self.verifyValidators)
def verifyValidators(self, app, buildSpec): def verifyValidators(self, app, buildSpec):

|||||||
100:0
Loading…
Cancel
Save