Skip to content

Commit

Permalink
add coverage, test 2.6, use -q, add ignores, fix some (but not all) r…
Browse files Browse the repository at this point in the history
…esource and test method warnings under 3.2
  • Loading branch information
mcdonc committed Apr 26, 2012
1 parent 0742ef2 commit ceeca3a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ bin/
include/ include/
lib/ lib/
local local
nosetests.xml
pyramid_deform/coverage.xml
.tox/
28 changes: 18 additions & 10 deletions pyramid_deform/tests.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def test_previous_success_at_step_zero(self):
state = request.session['pyramid_deform.wizards']['name'] state = request.session['pyramid_deform.wizards']['name']
self.assertEqual(state['states'][0], {'one':'one'}) self.assertEqual(state['states'][0], {'one':'one'})
self.assertEqual(state['states']['schema'], {'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): def test_previous_success_at_step_one(self):
from pyramid_deform import WizardState from pyramid_deform import WizardState
Expand Down Expand Up @@ -270,7 +270,7 @@ def test_previous_failure_at_step_zero(self):
self.assertEqual(result.status, '302 Found') self.assertEqual(result.status, '302 Found')
self.assertEqual(result.location, 'http://example.com') self.assertEqual(result.location, 'http://example.com')
state = request.session['pyramid_deform.wizards']['name'] 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): def test_previous_failure_at_step_one(self):
from pyramid_deform import WizardState from pyramid_deform import WizardState
Expand Down Expand Up @@ -325,8 +325,8 @@ def test__get_wizard_data_no_existing_data(self):
inst = self._makeOne(request) inst = self._makeOne(request)
data = inst._get_wizard_data() data = inst._get_wizard_data()
self.assertEqual(data, {}) self.assertEqual(data, {})
self.failUnless('name' in request.session['pyramid_deform.wizards']) self.assertTrue('name' in request.session['pyramid_deform.wizards'])
self.failUnless(request.session._changed) self.assertTrue(request.session._changed)


def test__get_wizard_data_with_existing_data(self): def test__get_wizard_data_with_existing_data(self):
request = DummyRequest() request = DummyRequest()
Expand All @@ -337,7 +337,7 @@ def test__get_wizard_data_with_existing_data(self):
inst.request = request inst.request = request
data = inst._get_wizard_data() data = inst._get_wizard_data()
self.assertEqual(data, state) self.assertEqual(data, state)
self.failIf(request.session._changed) self.assertFalse(request.session._changed)


def test_clear(self): def test_clear(self):
request = DummyRequest() request = DummyRequest()
Expand Down Expand Up @@ -526,11 +526,16 @@ def test_setitem_stream_file(self):
inst = self._makeOne(request) inst = self._makeOne(request)
here = os.path.dirname(__file__) here = os.path.dirname(__file__)
thisfile = os.path.join(here, 'tests.py') 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(inst.tempstore['a']['fp'].startswith(self.tempdir))
self.assertTrue(open(inst.tempstore['a']['fp'], 'rb').read(), with inst['a']['fp'] as f:
open(thisfile, 'rb').read()) received = f.read()
with open(thisfile, 'rb') as f:
expected = f.read()
self.assertTrue(expected, received)
self.assertTrue(request.session._changed) self.assertTrue(request.session._changed)
fp.close()


def test_get_data_None(self): def test_get_data_None(self):
request = self._makeRequest() request = self._makeRequest()
Expand All @@ -549,8 +554,11 @@ def test_get_basestring_fp(self):
here = os.path.dirname(__file__) here = os.path.dirname(__file__)
thisfile = os.path.join(here, 'tests.py') thisfile = os.path.join(here, 'tests.py')
inst.tempstore['a'] = {'fp':thisfile} inst.tempstore['a'] = {'fp':thisfile}
self.assertEqual(inst.get('a')['fp'].read(), with inst['a']['fp'] as f:
open(thisfile, 'rb').read()) received = f.read()
with open(thisfile, 'rb') as f:
expected = f.read()
self.assertEqual(expected, received)


def test___getitem___notfound(self): def test___getitem___notfound(self):
request = self._makeRequest() request = self._makeRequest()
Expand Down
17 changes: 14 additions & 3 deletions tox.ini
Original file line number Original file line Diff line number Diff line change
@@ -1,10 +1,21 @@
[tox] [tox]
envlist = py27,py32 envlist = py26,py27,py32,cover


[testenv] [testenv]
commands=python setup.py test commands =
python setup.py test -q
deps = deps =
nose nose
mock Mock
coverage 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.