Skip to content

Commit

Permalink
version 0.4, remove some deps, use pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
camillescott committed Mar 8, 2018
1 parent 56c1f7f commit ec4db1a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 63 deletions.
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion ficus/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.3
0.4
31 changes: 13 additions & 18 deletions ficus/tests/test_figuremanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
'''
Expand All @@ -23,40 +19,40 @@ 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
ncols.
'''

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.
Expand All @@ -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.'
27 changes: 0 additions & 27 deletions ficus/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
setuptools>=0.6.35
nose>=1.3.4
nose-capturestderr>=1.0
matplotlib>=1.4
5 changes: 2 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[nosetests]
verbosity=2
detailed-errors=1
[aliases]
test=pytest
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ def main():
author = 'Camille Scott',
author_email = '[email protected]',
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 )
Expand Down

0 comments on commit ec4db1a

Please sign in to comment.