Permalink
Browse files

Added tests for aliases of package and function names

  • Loading branch information...
mikej888 committed Oct 28, 2016
1 parent bbd9539 commit 1f643c44936a43744f7075e317f7d4d9d7a0b8c2
Showing with 64 additions and 0 deletions.
  1. +8 −0 integration_test/config/test_packages.yml
  2. +56 −0 integration_test/packages/run_numpy_as_opaque.py
@@ -6,6 +6,14 @@ test_cases:
outputs: [ out.txt ]
skip: "recipy raises 'KeyError: 'mode'' under Python 3 and 'ValueError: I/O operation on closed file' under Python 2 logging this function"
---
script: run_numpy_as_opaque.py
libraries: [ numpy ]
test_cases:
- arguments: [ opaque_savetxt ]
outputs: [ out.txt ]
- arguments: [ cryptic ]
outputs: [ out.txt ]
---
script: run_gdal.py
# recipy logs version as 'gdal v?'
# libraries: [ gdal ]
@@ -0,0 +1,56 @@
"""
Sample script that runs numpy functions logged by recipy, when
imported as aliases.
"""
# Copyright (c) 2016 University of Edinburgh.
from __future__ import (nested_scopes, generators, division,
absolute_import, with_statement,
print_function, unicode_literals)
import recipy
import os
import sys
import numpy as opaque
from numpy import savetxt as cryptic
from integration_test.packages.base import Base
class NumpyAsOpaqueSample(Base):
"""
Sample script that runs numpy functions logged by recipy,
when imported as aliases.
All functions that save files delete the files after saving,
to keep the directory clean.
"""
def __init__(self):
"""
Constructor.
"""
Base.__init__(self)
def opaque_savetxt(self):
"""
Use numpy.savetxt to save a file out.txt.
"""
file_name = os.path.join(self.current_dir, "out.txt")
data = opaque.arange(10)
opaque.savetxt(file_name, data)
os.remove(file_name)
def cryptic(self):
"""
Use numpy.savetxt to save a file out.txt.
"""
file_name = os.path.join(self.current_dir, "out.txt")
data = opaque.arange(10)
cryptic(file_name, data)
os.remove(file_name)
if __name__ == "__main__":
NumpyAsOpaqueSample().invoke(sys.argv)

0 comments on commit 1f643c4

Please sign in to comment.