summaryrefslogtreecommitdiff
path: root/numpy/f2py/tests/util.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2015-07-25 23:22:12 -0600
committerCharles Harris <charlesr.harris@gmail.com>2015-07-25 23:22:12 -0600
commit0fa1a9fa0a54fce6e741333308bdafa83c0663b2 (patch)
tree96ef2d826482ab52974efca8bfcf4c1940f3507b /numpy/f2py/tests/util.py
parenta0121573e6685f09e5f613280d616070b8ff99cb (diff)
downloadnumpy-0fa1a9fa0a54fce6e741333308bdafa83c0663b2.tar.gz
STY: PEP8 fixes in numpy/f2py/tests.
Diffstat (limited to 'numpy/f2py/tests/util.py')
-rw-r--r--numpy/f2py/tests/util.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py
index 56aff2b66..5b4e072e7 100644
--- a/numpy/f2py/tests/util.py
+++ b/numpy/f2py/tests/util.py
@@ -33,6 +33,7 @@ except ImportError:
_module_dir = None
+
def _cleanup():
global _module_dir
if _module_dir is not None:
@@ -46,6 +47,7 @@ def _cleanup():
pass
_module_dir = None
+
def get_module_dir():
global _module_dir
if _module_dir is None:
@@ -55,18 +57,21 @@ def get_module_dir():
sys.path.insert(0, _module_dir)
return _module_dir
+
def get_temp_module_name():
# Assume single-threaded, and the module dir usable only by this thread
d = get_module_dir()
for j in range(5403, 9999999):
name = "_test_ext_module_%d" % j
fn = os.path.join(d, name)
- if name not in sys.modules and not os.path.isfile(fn+'.py'):
+ if name not in sys.modules and not os.path.isfile(fn + '.py'):
return name
raise RuntimeError("Failed to create a temporary module name")
+
def _memoize(func):
memo = {}
+
def wrapper(*a, **kw):
key = repr((a, kw))
if key not in memo:
@@ -86,6 +91,7 @@ def _memoize(func):
# Building modules
#
+
@_memoize
def build_module(source_files, options=[], skip=[], only=[], module_name=None):
"""
@@ -144,6 +150,7 @@ def build_module(source_files, options=[], skip=[], only=[], module_name=None):
__import__(module_name)
return sys.modules[module_name]
+
@_memoize
def build_code(source_code, options=[], skip=[], only=[], suffix=None,
module_name=None):
@@ -169,6 +176,8 @@ def build_code(source_code, options=[], skip=[], only=[], suffix=None,
#
_compiler_status = None
+
+
def _get_compiler_status():
global _compiler_status
if _compiler_status is not None:
@@ -220,12 +229,15 @@ sys.exit(99)
# Finished
return _compiler_status
+
def has_c_compiler():
return _get_compiler_status()[0]
+
def has_f77_compiler():
return _get_compiler_status()[1]
+
def has_f90_compiler():
return _get_compiler_status()[2]
@@ -233,6 +245,7 @@ def has_f90_compiler():
# Building with distutils
#
+
@_memoize
def build_module_distutils(source_files, config_code, module_name, **kw):
"""
@@ -270,7 +283,7 @@ def configuration(parent_name='',top_path=None):
if __name__ == "__main__":
from numpy.distutils.core import setup
setup(configuration=configuration)
-""" % dict(config_code=config_code, syspath = repr(sys.path))
+""" % dict(config_code=config_code, syspath=repr(sys.path))
script = os.path.join(d, get_temp_module_name() + '.py')
dst_sources.append(script)
@@ -304,6 +317,7 @@ if __name__ == "__main__":
# Unittest convenience
#
+
class F2PyTest(object):
code = None
sources = None