climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r1523013 - /incubator/climate/trunk/ocw/tests/test_local.py
Date Fri, 13 Sep 2013 16:57:46 GMT
Author: joyce
Date: Fri Sep 13 16:57:46 2013
New Revision: 1523013

URL: http://svn.apache.org/r1523013
Log:
CLIMATE-297 - Fix test_local breaking if run outside of tests directory

- This is a pretty hacky way of fixing this problem. It uses the inspect
  module to get the location of the test_local module (which we also
  have to import in test_local, which is hideous). The path is then
  manipulated so that it points to the /trunk/examples folder. So, it
  doesn't break if you run outside of the tests folder but it does
  depend on the repo layout present at Apache. Ultimately, the outside
  dependencies should be removed if possible.

Modified:
    incubator/climate/trunk/ocw/tests/test_local.py

Modified: incubator/climate/trunk/ocw/tests/test_local.py
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/ocw/tests/test_local.py?rev=1523013&r1=1523012&r2=1523013&view=diff
==============================================================================
--- incubator/climate/trunk/ocw/tests/test_local.py (original)
+++ incubator/climate/trunk/ocw/tests/test_local.py Fri Sep 13 16:57:46 2013
@@ -21,6 +21,8 @@ import numpy.ma as ma
 import os
 import netCDF4
 import datetime
+import inspect
+import test_local # Import test_local so we can use inspect to get the path 
 import ocw.data_source.local as local
 
 
@@ -62,8 +64,11 @@ class test_load_file(unittest.TestCase):
         self.assertTrue(numpy.allclose(local.load_file(self.file_path, "value").values, new_values))
 
 class test_get_netcdf_variable_names(unittest.TestCase):
+    path_leader = inspect.getfile(test_local).split('ocw/')
+
     def setUp(self):
-        self.netcdf_path = os.path.abspath("../../examples/AFRICA_KNMI-RACMO2.2b_CTL_ERAINT_MM_50km_1989-2008_tasmax.nc")
+        file_path = os.path.join(self.path_leader[0], "examples/AFRICA_KNMI-RACMO2.2b_CTL_ERAINT_MM_50km_1989-2008_tasmax.nc")
+        self.netcdf_path = os.path.abspath(file_path)
         self.invalid_netcdf_path = create_invalid_dimensions_netcdf_object()
         self.netcdf = netCDF4.Dataset(self.netcdf_path, mode='r')
 



Mime
View raw message