Permalink
Browse files

add coverage, test 2.6, use -q, add ignores, fix some (but not all) r…

…esource and test method warnings under 3.2
  • Loading branch information...
1 parent 0742ef2 commit ceeca3ab93bb803bee511b264d1efbd88a773208 @mcdonc mcdonc committed Apr 26, 2012
Showing with 35 additions and 13 deletions.
  1. +3 −0 .gitignore
  2. +18 −10 pyramid_deform/tests.py
  3. +14 −3 tox.ini
View
@@ -8,3 +8,6 @@ bin/
include/
lib/
local
+nosetests.xml
+pyramid_deform/coverage.xml
+.tox/
View
@@ -222,7 +222,7 @@ def test_previous_success_at_step_zero(self):
state = request.session['pyramid_deform.wizards']['name']
self.assertEqual(state['states'][0], {'one':'one'})
self.assertEqual(state['states']['schema'], {'one':'one'})
- self.failIf('step' in state)
+ self.assertFalse('step' in state)
def test_previous_success_at_step_one(self):
from pyramid_deform import WizardState
@@ -270,7 +270,7 @@ def test_previous_failure_at_step_zero(self):
self.assertEqual(result.status, '302 Found')
self.assertEqual(result.location, 'http://example.com')
state = request.session['pyramid_deform.wizards']['name']
- self.failIf('step' in state)
+ self.assertFalse('step' in state)
def test_previous_failure_at_step_one(self):
from pyramid_deform import WizardState
@@ -325,8 +325,8 @@ def test__get_wizard_data_no_existing_data(self):
inst = self._makeOne(request)
data = inst._get_wizard_data()
self.assertEqual(data, {})
- self.failUnless('name' in request.session['pyramid_deform.wizards'])
- self.failUnless(request.session._changed)
+ self.assertTrue('name' in request.session['pyramid_deform.wizards'])
+ self.assertTrue(request.session._changed)
def test__get_wizard_data_with_existing_data(self):
request = DummyRequest()
@@ -337,7 +337,7 @@ def test__get_wizard_data_with_existing_data(self):
inst.request = request
data = inst._get_wizard_data()
self.assertEqual(data, state)
- self.failIf(request.session._changed)
+ self.assertFalse(request.session._changed)
def test_clear(self):
request = DummyRequest()
@@ -526,11 +526,16 @@ def test_setitem_stream_file(self):
inst = self._makeOne(request)
here = os.path.dirname(__file__)
thisfile = os.path.join(here, 'tests.py')
- inst['a'] = {'fp':open(thisfile, 'rb')}
+ fp = open(thisfile, 'rb')
+ inst['a'] = {'fp': fp}
self.assertTrue(inst.tempstore['a']['fp'].startswith(self.tempdir))
- self.assertTrue(open(inst.tempstore['a']['fp'], 'rb').read(),
- open(thisfile, 'rb').read())
+ with inst['a']['fp'] as f:
+ received = f.read()
+ with open(thisfile, 'rb') as f:
+ expected = f.read()
+ self.assertTrue(expected, received)
self.assertTrue(request.session._changed)
+ fp.close()
def test_get_data_None(self):
request = self._makeRequest()
@@ -549,8 +554,11 @@ def test_get_basestring_fp(self):
here = os.path.dirname(__file__)
thisfile = os.path.join(here, 'tests.py')
inst.tempstore['a'] = {'fp':thisfile}
- self.assertEqual(inst.get('a')['fp'].read(),
- open(thisfile, 'rb').read())
+ with inst['a']['fp'] as f:
+ received = f.read()
+ with open(thisfile, 'rb') as f:
+ expected = f.read()
+ self.assertEqual(expected, received)
def test___getitem___notfound(self):
request = self._makeRequest()
View
17 tox.ini
@@ -1,10 +1,21 @@
[tox]
-envlist = py27,py32
+envlist = py26,py27,py32,cover
[testenv]
-commands=python setup.py test
+commands =
+ python setup.py test -q
deps =
nose
- mock
+ Mock
coverage
+[testenv:cover]
+basepython =
+ python2.6
+commands =
+ python setup.py nosetests --with-xunit --with-xcoverage
+deps =
+ nose
+ Mock
+ coverage
+ nosexcover

0 comments on commit ceeca3a

Please sign in to comment.