From ec4db1a9af45cdf4014b34978cc6c2416945bdee Mon Sep 17 00:00:00 2001 From: Camille Scott Date: Wed, 7 Mar 2018 17:29:26 -0800 Subject: [PATCH] version 0.4, remove some deps, use pytest --- Makefile | 8 -------- ficus/VERSION | 2 +- ficus/tests/test_figuremanager.py | 31 +++++++++++++------------------ ficus/tests/utils.py | 27 --------------------------- requirements.txt | 2 -- setup.cfg | 5 ++--- setup.py | 7 +++---- 7 files changed, 19 insertions(+), 63 deletions(-) diff --git a/Makefile b/Makefile index ff097e2..e41d4c8 100644 --- a/Makefile +++ b/Makefile @@ -12,14 +12,6 @@ test: FORCE publish: FORCE python setup.py sdist upload -#gh-pages: -# cd doc; make clean html -# touch doc/_build/html/.nojekyll -# git add doc/ -# git commit -m "Generated gh-pages for `git log master -1 --pretty=short --abbrev-commit`" -# git subtree push --prefix doc/_build/html origin gh-pages - - clean: FORCE rm -rf build/ *.pyc ficus/*.pyc ficus/*.egg-info *.egg-info diff --git a/ficus/VERSION b/ficus/VERSION index 1c09c74..bd73f47 100644 --- a/ficus/VERSION +++ b/ficus/VERSION @@ -1 +1 @@ -0.3.3 +0.4 diff --git a/ficus/tests/test_figuremanager.py b/ficus/tests/test_figuremanager.py index c0833ae..556cfa3 100644 --- a/ficus/tests/test_figuremanager.py +++ b/ficus/tests/test_figuremanager.py @@ -6,15 +6,11 @@ import os from unittest import TestCase -from utils import TemporaryDirectory, Move, TestData, touch, TemporaryFile +from utils import TemporaryDirectory, Move, touch, TemporaryFile from ficus import FigureManager class TestFigureManager(TestCase): - @classmethod - def setup_class(cls): - pass - def test_save(self): '''Test that FigureManager saves a plot. ''' @@ -23,27 +19,27 @@ def test_save(self): with FigureManager(filename=filename + '.pdf') as (fig, ax): ax.plot(range(10), range(10)) - self.assertTrue(os.path.isfile(filename + '.pdf')) + assert os.path.isfile(filename + '.pdf') def test_subplots_nrows(self): '''Test that FigureManager generates multiple subplots with nrows. ''' with FigureManager(nrows=3) as (fig, ax): - self.assertEqual(len(ax), 3) - self.assertIs(type(fig), figure.Figure) + assert len(ax) == 3 + assert type(fig) is figure.Figure for axis in ax: - self.assertIsInstance(axis, axes.Axes) + assert isinstance(axis, axes.Axes) def test_subplots_ncols(self): '''Test that FigureManager generates multiple subplots with ncols. ''' with FigureManager(ncols=3) as (fig, ax): - self.assertEqual(len(ax), 3) - self.assertIsInstance(fig, figure.Figure) + assert len(ax) == 3 + assert isinstance(fig, figure.Figure) for axis in ax: - self.assertIsInstance(axis, axes.Axes) + assert isinstance(axis, axes.Axes) def test_subplots_nrows_ncols(self): '''Test that FigureManager generates multiple subplots with nrows and @@ -51,12 +47,12 @@ def test_subplots_nrows_ncols(self): ''' with FigureManager(nrows=3, ncols=3) as (fig, ax): - self.assertEqual(len(ax), 3) - self.assertEqual(len(ax[0]), 3) - self.assertIsInstance(fig, figure.Figure) + assert len(ax) == 3 + assert len(ax[0]) == 3 + assert isinstance(fig, figure.Figure) for axrow in ax: for axis in axrow: - self.assertIsInstance(axis, axes.Axes) + assert isinstance(axis, axes.Axes) def test_exception(self): '''Test that FigureManager handles internal exceptions properly. @@ -72,5 +68,4 @@ def test_exception(self): with rregexp(RuntimeError, 'TEST'): with FigureManager(filename=filename) as (fig, ax): raise RuntimeError('TEST') - self.assertFalse(os.path.isfile(filename), - msg='Should not have saved a file.') + assert not os.path.isfile(filename), 'Should not have saved a file.' diff --git a/ficus/tests/utils.py b/ficus/tests/utils.py index 1d8060f..1565101 100644 --- a/ficus/tests/utils.py +++ b/ficus/tests/utils.py @@ -22,33 +22,6 @@ def touch(filename): _os.chmod(filename, stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) -class TestData(object): - - def __init__(self, filename, dest_dir): - self.filepath = None - try: - self.filepath = resource_filename(Requirement.parse("dammit"), - "dammit/tests/test-data/" + filename) - except ResolutionError: - pass - if not self.filepath or not _os.path.isfile(self.filepath): - self.filepath = _os.path.join(_os.path.dirname(__file__), - 'test-data', filename) - shutil.copy(self.filepath, dest_dir) - self.filepath = _os.path.join(dest_dir, filename) - - def __enter__(self): - return self.filepath - - def __exit__(self, exc_type, exc_value, traceback): - try: - _os.remove(self.filepath) - except OSError: - pass - if exc_type: - return False - - class TemporaryFile(object): def __init__(self, directory): diff --git a/requirements.txt b/requirements.txt index 0d5732e..9d1d10d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,2 @@ setuptools>=0.6.35 -nose>=1.3.4 -nose-capturestderr>=1.0 matplotlib>=1.4 diff --git a/setup.cfg b/setup.cfg index 193d216..b7e4789 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,2 @@ -[nosetests] -verbosity=2 -detailed-errors=1 +[aliases] +test=pytest diff --git a/setup.py b/setup.py index 2b59239..dc71da7 100755 --- a/setup.py +++ b/setup.py @@ -28,12 +28,11 @@ def main(): author = 'Camille Scott', author_email = 'camille.scott.w@gmail.com', license = 'BSD', - test_suite = 'nose.collector', - tests_require = ['nose'], + tests_require = ['pytest', 'pytest-runner'], packages = ['ficus'], + setup_requires = ['pytest-runner', 'pytest'], install_requires = ['nose>=1.3.4', - 'matplotlib>=1.4', - 'nose-capturestderr>=1.0'], + 'matplotlib>=1.4'], include_package_data = True, zip_safe = False, cmdclass = cmdclass )