[pyfai] 03/10: add patch to clean the temps files during the tests

Frédéric-Emmanuel Picca picca at moszumanska.debian.org
Mon Jan 13 23:05:29 UTC 2014


This is an automated email from the git hooks/post-receive script.

picca pushed a commit to branch experimental
in repository pyfai.

commit d46d4425f5a80c420a2590c22bcc5ac8929f2ffd
Author: Picca Frédéric-Emmanuel <picca at debian.org>
Date:   Sat Dec 28 12:01:39 2013 +0100

    add patch to clean the temps files during the tests
---
 ...warded-setup-teardown-to-remove-temporary.patch | 143 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 debian/rules                                       |  11 --
 3 files changed, 144 insertions(+), 11 deletions(-)

diff --git a/debian/patches/0001-feature-forwarded-setup-teardown-to-remove-temporary.patch b/debian/patches/0001-feature-forwarded-setup-teardown-to-remove-temporary.patch
new file mode 100644
index 0000000..b02b461
--- /dev/null
+++ b/debian/patches/0001-feature-forwarded-setup-teardown-to-remove-temporary.patch
@@ -0,0 +1,143 @@
+From: =?utf-8?q?Picca_Fr=C3=A9d=C3=A9ric-Emmanuel?= <picca at debian.org>
+Date: Sat, 28 Dec 2013 12:00:17 +0100
+Subject: feature forwarded setup teardown to remove temporary files
+
+---
+ test/testAzimuthalIntegrator.py | 34 +++++++++++++++++++++++++++-------
+ test/testPeakPicking.py         | 13 +++++++++----
+ 2 files changed, 36 insertions(+), 11 deletions(-)
+
+diff --git a/test/testAzimuthalIntegrator.py b/test/testAzimuthalIntegrator.py
+index 8fb3cc7..834b270 100755
+--- a/test/testAzimuthalIntegrator.py
++++ b/test/testAzimuthalIntegrator.py
+@@ -38,6 +38,8 @@ import numpy
+ import logging, time
+ import sys
+ import fabio
++import shutil
++import tempfile
+ 
+ from utilstest import UtilsTest, Rwp, getLogger
+ logger = getLogger(__file__)
+@@ -46,6 +48,9 @@ from pyFAI.azimuthalIntegrator import AzimuthalIntegrator
+ if logger.getEffectiveLevel() <= logging.INFO:
+     import pylab
+ 
++dirname = os.path.dirname(os.path.abspath(__file__))
++
++
+ class test_azim_halfFrelon(unittest.TestCase):
+     """basic test"""
+     fit2dFile = '1460/fit2d.dat'
+@@ -61,6 +66,9 @@ class test_azim_halfFrelon(unittest.TestCase):
+         self.halfFrelon = UtilsTest.getimage(self.__class__.halfFrelon)
+         self.splineFile = UtilsTest.getimage(self.__class__.splineFile)
+         self.poniFile = UtilsTest.getimage(self.__class__.poniFile)
++
++        self.tmpdir = tempfile.mkdtemp(dir=dirname)
++
+         with open(self.poniFile) as f:
+             data = []
+             for line in f:
+@@ -74,8 +82,9 @@ class test_azim_halfFrelon(unittest.TestCase):
+         self.ai = AzimuthalIntegrator()
+         self.ai.load(self.poniFile)
+         self.data = fabio.open(self.halfFrelon).data
+-        if not os.path.isdir("tmp"):
+-            os.mkdir("tmp")
++
++    def tearDown(self):
++        shutil.rmtree(self.tmpdir, True)
+ 
+     def test_numpy_vs_fit2d(self):
+         """
+@@ -83,7 +92,9 @@ class test_azim_halfFrelon(unittest.TestCase):
+         """
+ #        logger.info(self.ai.__repr__())
+         tth, I = self.ai.xrpd_numpy(self.data,
+-                                     len(self.fit2d), "tmp/numpy.dat", correctSolidAngle=False)
++                                    len(self.fit2d),
++                                    os.path.join(self.tmpdir, "numpy.dat"),
++                                    correctSolidAngle=False)
+         rwp = Rwp((tth, I), self.fit2d.T)
+         logger.info("Rwp numpy/fit2d = %.3f" % rwp)
+         if logger.getEffectiveLevel() == logging.DEBUG:
+@@ -105,7 +116,9 @@ class test_azim_halfFrelon(unittest.TestCase):
+         """
+ #        logger.info(self.ai.__repr__())
+         tth, I = self.ai.xrpd_cython(self.data,
+-                                     len(self.fit2d), "tmp/cython.dat", correctSolidAngle=False, pixelSize=None)
++                                     len(self.fit2d),
++                                     os.path.join(self.tmpdir, "cython.dat"),
++                                     correctSolidAngle=False, pixelSize=None)
+ #        logger.info(tth)
+ #        logger.info(I)
+         rwp = Rwp((tth, I), self.fit2d.T)
+@@ -133,7 +146,10 @@ class test_azim_halfFrelon(unittest.TestCase):
+         logger.info("in test_cythonSP_vs_fit2d Before SP")
+ 
+         tth, I = self.ai.xrpd_splitPixel(self.data,
+-                                     len(self.fit2d), "tmp/cythonSP.dat", correctSolidAngle=False)
++                                         len(self.fit2d),
++                                         os.path.join(self.tmpdir,
++                                                      "cythonSP.dat"),
++                                         correctSolidAngle=False)
+         logger.info("in test_cythonSP_vs_fit2d Before")
+         t1 = time.time() - t0
+ #        logger.info(tth)
+@@ -239,10 +255,14 @@ class test_saxs(unittest.TestCase):
+         self.poniFile = UtilsTest.getimage(self.__class__.poniFile)
+         self.maskRef = UtilsTest.getimage(self.__class__.maskRef)
+         self.maskDummy = UtilsTest.getimage(self.__class__.maskDummy)
++
++        self.tmpdir = tempfile.mkdtemp(dir=dirname)
++
+         self.ai = AzimuthalIntegrator()
+         self.ai.load(self.poniFile)
+-        if not os.path.isdir("tmp"):
+-            os.mkdir("tmp")
++
++    def tearDown(self):
++        shutil.rmtree(self.tmpdir, True)
+ 
+     def test_mask(self):
+         """test the generation of mask"""
+diff --git a/test/testPeakPicking.py b/test/testPeakPicking.py
+index b37b7df..2377174 100755
+--- a/test/testPeakPicking.py
++++ b/test/testPeakPicking.py
+@@ -38,6 +38,9 @@ import numpy
+ import logging, time
+ import sys
+ import fabio
++import shutil
++import tempfile
++
+ from utilstest import UtilsTest, Rwp, getLogger
+ logger = getLogger(__file__)
+ pyFAI = sys.modules["pyFAI"]
+@@ -47,6 +50,8 @@ from pyFAI.geometryRefinement import GeometryRefinement
+ if logger.getEffectiveLevel() <= logging.INFO:
+     import pylab
+ 
++dirname = os.path.dirname(os.path.abspath(__file__))
++
+ 
+ class test_peak_picking(unittest.TestCase):
+     """basic test"""
+@@ -72,10 +77,10 @@ class test_peak_picking(unittest.TestCase):
+         """Download files"""
+         self.img = UtilsTest.getimage(self.__class__.calibFile)
+         self.pp = PeakPicker(self.img, dSpacing=self.ds, wavelength=self.wavelength)
+-        dirname = os.path.dirname(os.path.abspath(__file__))
+-        self.tmpdir = os.path.join(dirname, "tmp")
+-        if not os.path.isdir(self.tmpdir):
+-            os.mkdir(self.tmpdir)
++        self.tmpdir = tempfile.mkdtemp(dir=dirname)
++
++    def tearDown(self):
++        shutil.rmtree(self.tmpdir, True)
+ 
+     def test_peakPicking(self):
+         """first test peak-picking then checks the geometry found is OK"""
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..c2996ec
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+0001-feature-forwarded-setup-teardown-to-remove-temporary.patch
diff --git a/debian/rules b/debian/rules
index 2c001cd..f3b223e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -4,17 +4,6 @@ export DH_VERBOSE=1
 
 PYVERS=$(shell pyversions -vs)
 
-override_dh_clean:
-	dh_clean
-
-	# remove test files
-	rm -f test/merged01-numpy_array.edf
-	rm -f test/tmp/testpeakPicking.npt
-	rm -f test/tmp/cython.dat
-	rm -f test/tmp/cythonSP.dat
-	rm -f test/tmp/numpy.dat
-	rm -f test/tmp/testpeakPicking.log
-
 override_dh_auto_install:
 	dh_auto_install
 	dh_numpy

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pyfai.git



More information about the debian-science-commits mailing list