[yt-svn] commit/yt: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Wed Dec 19 11:31:16 PST 2012
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/4ba75d3666fe/
changeset: 4ba75d3666fe
branch: yt
user: xarthisius
date: 2012-12-18 10:13:48
summary: Update PlotWindow testsuite
affected #: 1 file
diff -r 4174ccdee99da445bf1a92919a3ae41abab53b2f -r 4ba75d3666fea3ce254b0f2a0265c786e5014d59 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -1,58 +1,97 @@
-from yt.testing import *
-from yt.mods import SlicePlot, ProjectionPlot, \
- OffAxisSlicePlot, OffAxisProjectionPlot
+"""
+Testsuite for PlotWindow class
+
+Author: Nathan Goldbaum <goldbaum at ucolick.org>
+Affiliation: UCSC Astronomy
+Homepage: http://yt-project.org/
+License:
+ Copyright (C) 2012 Nathan Goldbaum. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
import os
+import sys
+import tempfile
+import shutil
+from yt.testing import \
+ fake_random_pf
+from yt.mods import \
+ SlicePlot, ProjectionPlot, OffAxisSlicePlot, OffAxisProjectionPlot
+
+
+EXT_TO_TYPE = {
+ '.ps': 'PostScript document text conforming DSC level 3.0',
+ '.eps': 'PostScript document text conforming DSC level 3.0, type EPS',
+ '.pdf': 'PDF document, version 1.4',
+ '.png': 'PNG image data, 1070 x 1000, 8-bit/color RGBA, non-interlaced'
+}
+
def setup():
+ """Test specific setup."""
from yt.config import ytcfg
- ytcfg["yt","__withintesting"] = "True"
+ ytcfg["yt", "__withintesting"] = "True"
-def teardown_func(fns):
- for fn in np.unique(fns):
- os.remove(fn)
-ext_to_mime = {'.ps' : 'application/postscript',
- '.eps' : 'application/postscript',
- '.pdf' : 'application/pdf',
- '.png' : 'image/png' }
+def assert_fname(fname):
+ """Function that checks file type using libmagic"""
+ if fname is None:
+ return
-def assert_fn(fn):
- if fn is None:
- return
try:
import magic
- ext = os.path.splitext(fn)[1]
- magic_text = magic.from_file(fn,mime=True)
- print fn, magic_text, ext_to_mime[ext]
- assert magic_text == ext_to_mime[ext]
except ImportError:
# OS X doesn't come with libmagic
- pass
+ pass
+
+ if 'magic' in sys.modules:
+ ext = os.path.splitext(fname)[1]
+ mds = magic.open(magic.MAGIC_NONE)
+ mds.load()
+ magic_text = mds.file(fname)
+ mds.close()
+ assert magic_text == EXT_TO_TYPE[ext]
+
def test_plotwindow():
- pf = fake_random_pf(64)
- fns = []
- test_flnms = [None, 'test.png', 'test.eps',
+ """Main test suite for PlotWindow."""
+ # Perform I/O in safe place instead of yt main dir
+ tmpdir = tempfile.mkdtemp()
+ curdir = os.getcwd()
+ os.chdir(tmpdir)
+
+ normal = [1, 1, 1]
+
+ test_pf = fake_random_pf(64)
+ test_flnms = [None, 'test.png', 'test.eps',
'test.ps', 'test.pdf']
- for fn in test_flnms:
- for dim in [0,1,2]:
- slc = SlicePlot(pf, dim, 'Density')
- fns.append(slc.save(fn)[0])
- assert_fn(fn)
+ for fname in test_flnms:
+ for dim in [0, 1, 2]:
+ obj = SlicePlot(test_pf, dim, 'Density')
+ assert_fname(obj.save(fname)[0])
- prj = ProjectionPlot(pf, dim, 'Density')
- fns.append(prj.save(fn)[0])
- assert_fn(fn)
-
- normal = [1,1,1]
-
- oaslc = OffAxisSlicePlot(pf, normal, 'Density')
- fns.append(oaslc.save(fn)[0])
- assert_fn(fn)
+ obj = ProjectionPlot(test_pf, dim, 'Density')
+ assert_fname(obj.save(fname)[0])
- oaprj = OffAxisProjectionPlot(pf, normal, 'Density')
- fns.append(oaprj.save(fn)[0])
- assert_fn(fn)
-
- teardown_func(fns)
-
+ obj = OffAxisSlicePlot(test_pf, normal, 'Density')
+ assert_fname(obj.save(fname)[0])
+
+ obj = OffAxisProjectionPlot(test_pf, normal, 'Density')
+ assert_fname(obj.save(fname)[0])
+
+ os.chdir(curdir)
+ # clean up
+ shutil.rmtree(tmpdir)
https://bitbucket.org/yt_analysis/yt/changeset/fa22322ff149/
changeset: fa22322ff149
branch: yt
user: MatthewTurk
date: 2012-12-19 20:31:14
summary: Merged in xarthisius/yt (pull request #379: Update PlotWindow testsuite)
affected #: 1 file
diff -r 38d19fd66171bb88b0a4561420d304b078be6f95 -r fa22322ff1494d97e851748f8e78523e5a2b77ad yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -1,58 +1,97 @@
-from yt.testing import *
-from yt.mods import SlicePlot, ProjectionPlot, \
- OffAxisSlicePlot, OffAxisProjectionPlot
+"""
+Testsuite for PlotWindow class
+
+Author: Nathan Goldbaum <goldbaum at ucolick.org>
+Affiliation: UCSC Astronomy
+Homepage: http://yt-project.org/
+License:
+ Copyright (C) 2012 Nathan Goldbaum. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
import os
+import sys
+import tempfile
+import shutil
+from yt.testing import \
+ fake_random_pf
+from yt.mods import \
+ SlicePlot, ProjectionPlot, OffAxisSlicePlot, OffAxisProjectionPlot
+
+
+EXT_TO_TYPE = {
+ '.ps': 'PostScript document text conforming DSC level 3.0',
+ '.eps': 'PostScript document text conforming DSC level 3.0, type EPS',
+ '.pdf': 'PDF document, version 1.4',
+ '.png': 'PNG image data, 1070 x 1000, 8-bit/color RGBA, non-interlaced'
+}
+
def setup():
+ """Test specific setup."""
from yt.config import ytcfg
- ytcfg["yt","__withintesting"] = "True"
+ ytcfg["yt", "__withintesting"] = "True"
-def teardown_func(fns):
- for fn in np.unique(fns):
- os.remove(fn)
-ext_to_mime = {'.ps' : 'application/postscript',
- '.eps' : 'application/postscript',
- '.pdf' : 'application/pdf',
- '.png' : 'image/png' }
+def assert_fname(fname):
+ """Function that checks file type using libmagic"""
+ if fname is None:
+ return
-def assert_fn(fn):
- if fn is None:
- return
try:
import magic
- ext = os.path.splitext(fn)[1]
- magic_text = magic.from_file(fn,mime=True)
- print fn, magic_text, ext_to_mime[ext]
- assert magic_text == ext_to_mime[ext]
except ImportError:
# OS X doesn't come with libmagic
- pass
+ pass
+
+ if 'magic' in sys.modules:
+ ext = os.path.splitext(fname)[1]
+ mds = magic.open(magic.MAGIC_NONE)
+ mds.load()
+ magic_text = mds.file(fname)
+ mds.close()
+ assert magic_text == EXT_TO_TYPE[ext]
+
def test_plotwindow():
- pf = fake_random_pf(64)
- fns = []
- test_flnms = [None, 'test.png', 'test.eps',
+ """Main test suite for PlotWindow."""
+ # Perform I/O in safe place instead of yt main dir
+ tmpdir = tempfile.mkdtemp()
+ curdir = os.getcwd()
+ os.chdir(tmpdir)
+
+ normal = [1, 1, 1]
+
+ test_pf = fake_random_pf(64)
+ test_flnms = [None, 'test.png', 'test.eps',
'test.ps', 'test.pdf']
- for fn in test_flnms:
- for dim in [0,1,2]:
- slc = SlicePlot(pf, dim, 'Density')
- fns.append(slc.save(fn)[0])
- assert_fn(fn)
+ for fname in test_flnms:
+ for dim in [0, 1, 2]:
+ obj = SlicePlot(test_pf, dim, 'Density')
+ assert_fname(obj.save(fname)[0])
- prj = ProjectionPlot(pf, dim, 'Density')
- fns.append(prj.save(fn)[0])
- assert_fn(fn)
-
- normal = [1,1,1]
-
- oaslc = OffAxisSlicePlot(pf, normal, 'Density')
- fns.append(oaslc.save(fn)[0])
- assert_fn(fn)
+ obj = ProjectionPlot(test_pf, dim, 'Density')
+ assert_fname(obj.save(fname)[0])
- oaprj = OffAxisProjectionPlot(pf, normal, 'Density')
- fns.append(oaprj.save(fn)[0])
- assert_fn(fn)
-
- teardown_func(fns)
-
+ obj = OffAxisSlicePlot(test_pf, normal, 'Density')
+ assert_fname(obj.save(fname)[0])
+
+ obj = OffAxisProjectionPlot(test_pf, normal, 'Density')
+ assert_fname(obj.save(fname)[0])
+
+ os.chdir(curdir)
+ # clean up
+ shutil.rmtree(tmpdir)
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list