From fe167efca5ce4fb487f3ece479719e5dfa886ec6 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Fri, 19 Feb 2016 11:56:09 +0100 Subject: [PATCH] Make the python tests runnable from any directory But note that if run from a directory other that the base of the package it is the installed package which is tested. --- python/crankshaft/test/helper.py | 6 ++++++ python/crankshaft/test/test_clustering_moran.py | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/python/crankshaft/test/helper.py b/python/crankshaft/test/helper.py index b87a12a..7d28b94 100644 --- a/python/crankshaft/test/helper.py +++ b/python/crankshaft/test/helper.py @@ -5,3 +5,9 @@ plpy = MockPlPy() import sys sys.modules['plpy'] = plpy + +import os + +def fixture_file(name): + dir = os.path.dirname(os.path.realpath(__file__)) + return os.path.join(dir, 'fixtures', name) diff --git a/python/crankshaft/test/test_clustering_moran.py b/python/crankshaft/test/test_clustering_moran.py index 6f3fa14..2e730a1 100644 --- a/python/crankshaft/test/test_clustering_moran.py +++ b/python/crankshaft/test/test_clustering_moran.py @@ -9,7 +9,7 @@ import unittest # # import sys # sys.modules['plpy'] = plpy -from helper import plpy +from helper import plpy, fixture_file import crankshaft.clustering as cc from crankshaft import random_seeds @@ -26,8 +26,8 @@ class MoranTest(unittest.TestCase): "table": "a_list", "geom_col": "the_geom", "num_ngbrs": 321} - self.neighbors_data = json.loads(open('test/fixtures/neighbors.json').read()) - self.moran_data = json.loads(open('test/fixtures/moran.json').read()) + self.neighbors_data = json.loads(open(fixture_file('neighbors.json')).read()) + self.moran_data = json.loads(open(fixture_file('moran.json')).read()) def test_map_quads(self): """Test map_quads."""