[Python-modules-commits] [cf-python] 09/14: Test fixes
Klaus Zimmermann
zklaus-guest at moszumanska.debian.org
Mon Sep 19 15:52:01 UTC 2016
This is an automated email from the git hooks/post-receive script.
zklaus-guest pushed a commit to branch master
in repository cf-python.
commit cb0f225a844796af205b9963b62b708f6215c997
Author: Klaus Zimmermann <klaus_zimmermann at gmx.de>
Date: Fri Sep 16 11:11:48 2016 +0200
Test fixes
Move some class variables to setUp methods in order to avoid import errors.
Added skipping of tests relying on esmf.
Signed-off-by: Klaus Zimmermann <klaus_zimmermann at gmx.de>
---
test/test_Field.py | 39 ++++++++++++++++++---------------------
test/test_Regrid.py | 2 ++
test/test_Variable.py | 15 +++++++--------
test/test_general.py | 9 ++++-----
4 files changed, 31 insertions(+), 34 deletions(-)
diff --git a/test/test_Field.py b/test/test_Field.py
index 1816060..a144580 100644
--- a/test/test_Field.py
+++ b/test/test_Field.py
@@ -6,27 +6,24 @@ import inspect
import datetime
class FieldTest(unittest.TestCase):
- filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
- 'test_file.nc')
-
- filename2 = os.path.join(os.path.dirname(os.path.abspath(__file__)),
- 'test_file2.nc')
-
- chunk_sizes = (17, 34, 300, 100000)[::-1]
- original_chunksize = cf.CHUNKSIZE()
-
- f = cf.read(filename)[0]
-
- test_only = ()
-# test_only = ('test_Field_transpose','test_Field_squeeze',)
-# test_only = ('test_Field_collapse',)
-# test_only = ('test_Field_match','test_Field_items',)
-# test_only = ('test_Field_items',)
-# test_only = ('test_Field_axes','test_Field_data_axes',)
-# test_only = ('test_Field_where',)
-# test_only = ('test_Field_anchor',)
-# test_only = ('test_Field_period',)
-# test_only = ('test_FieldList_argless_methods',)
+ def setUp(self):
+ self.filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+ 'test_file.nc')
+ self.filename2 = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+ 'test_file2.nc')
+ self.chunk_sizes = (17, 34, 300, 100000)[::-1]
+ self.original_chunksize = cf.CHUNKSIZE()
+ self.f = cf.read(self.filename)[0]
+ self.test_only = ()
+ # self.test_only = ('test_Field_transpose','test_Field_squeeze',)
+ # self.test_only = ('test_Field_collapse',)
+ # self.test_only = ('test_Field_match','test_Field_items',)
+ # self.test_only = ('test_Field_items',)
+ # self.test_only = ('test_Field_axes','test_Field_data_axes',)
+ # self.test_only = ('test_Field_where',)
+ # self.test_only = ('test_Field_anchor',)
+ # self.test_only = ('test_Field_period',)
+ # self.test_only = ('test_FieldList_argless_methods',)
def test_Field_anchor(self):
if self.test_only and inspect.stack()[0][3] not in self.test_only:
diff --git a/test/test_Regrid.py b/test/test_Regrid.py
index b182ac9..4eff69a 100644
--- a/test/test_Regrid.py
+++ b/test/test_Regrid.py
@@ -38,6 +38,7 @@ class RegridTest(unittest.TestCase):
# test_only('test_Field_section',)
# test_only('test_Data_section',)
+ @unittest.skipUnless(cf._found_ESMF, "Requires esmf package.")
def test_Field_regrids(self):
if self.test_only and inspect.stack()[0][3] not in self.test_only:
return
@@ -72,6 +73,7 @@ class RegridTest(unittest.TestCase):
cf.ATOL(original_atol)
#--- End: def
+ @unittest.skipUnless(cf._found_ESMF, "Requires esmf package.")
def test_Field_regridc(self):
if self.test_only and inspect.stack()[0][3] not in self.test_only:
return
diff --git a/test/test_Variable.py b/test/test_Variable.py
index 97a47ba..e0dbe4c 100644
--- a/test/test_Variable.py
+++ b/test/test_Variable.py
@@ -5,14 +5,13 @@ import unittest
import inspect
class VariableTest(unittest.TestCase):
- filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
- 'test_file.nc')
- chunk_sizes = (17, 34, 300, 100000)[::-1]
- original_chunksize = cf.CHUNKSIZE()
-
- f = cf.read(filename)[0]
-
- test_only = ()
+ def setUp(self):
+ self.filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+ 'test_file.nc')
+ self.chunk_sizes = (17, 34, 300, 100000)[::-1]
+ self.original_chunksize = cf.CHUNKSIZE()
+ self.f = cf.read(self.filename)[0]
+ self.test_only = ()
def test_Variable_max_mean_mid_range_min_range_sd_sum_var(self):
if self.test_only and inspect.stack()[0][3] not in self.test_only:
diff --git a/test/test_general.py b/test/test_general.py
index 340fd3b..f14d34f 100644
--- a/test/test_general.py
+++ b/test/test_general.py
@@ -27,11 +27,10 @@ atexit.register(_remove_tmpfiles)
class generalTest(unittest.TestCase):
- filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
- 'test_file.nc')
- chunk_sizes = (17, 34, 300, 100000)[::-1]
-
- f = cf.read(filename)[0]
+ def setUp(self):
+ filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+ 'test_file.nc')
+ self.f = cf.read(filename)[0]
def test_GENERAL(self):
# Save original chunksize
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/cf-python.git
More information about the Python-modules-commits
mailing list