Re: Using asserts in test code

2010-12-26 Thread Alex Gaynor
On Sun, Dec 26, 2010 at 9:55 PM, Will Hardy wrote: > It's true that there isn't any rich API for the Error/Fail distinction. The > best I can think of would be to create a custom exception eg > FailedAssumption, which is raised when the TestCase.failedException (same as > AssertionError) is caugh

Re: Using asserts in test code

2010-12-26 Thread Will Hardy
It's true that there isn't any rich API for the Error/Fail distinction. The best I can think of would be to create a custom exception eg FailedAssumption, which is raised when the TestCase.failedException (same as AssertionError) is caught while testing an assumption. Here are four ways I can thin

Re: Using asserts in test code

2010-12-25 Thread Russell Keith-Magee
On 25/12/2010, at 3:33 AM, Alex Gaynor wrote: > > > On Fri, Dec 24, 2010 at 12:56 PM, Will Hardy wrote: > Maybe we could add a keyword argument to Django's TestCase.assert*() methods > that raises an AssertionError instead of failing the test when the method's > condition is not met (I assu

Re: Using asserts in test code

2010-12-24 Thread Alex Gaynor
On Fri, Dec 24, 2010 at 12:56 PM, Will Hardy wrote: > Maybe we could add a keyword argument to Django's TestCase.assert*() > methods that raises an AssertionError instead of failing the test when the > method's condition is not met (I assume that the test should error instead > of failing). > > e

Re: Using asserts in test code

2010-12-24 Thread Will Hardy
Maybe we could add a keyword argument to Django's TestCase.assert*() methods that raises an AssertionError instead of failing the test when the method's condition is not met (I assume that the test should error instead of failing). eg: self.assertEqual(1, 1, test_assumption=True) Cheers, Will

Re: Using asserts in test code

2010-12-23 Thread Luke Plant
On Thu, 2010-12-23 at 11:46 -0500, Karen Tracey wrote: > Well, great, status wasn't 200 but what was it? That's information I'd > really rather get by default, so I much prefer assertEquals, which > tells me: > > Traceback (most recent call last): > File [snipped] > self.assertEqual(res.stat

Re: Using asserts in test code

2010-12-23 Thread Ɓukasz Rekucki
On 23 December 2010 17:56, Ian Clelland wrote: > On Thu, Dec 23, 2010 at 8:46 AM, Karen Tracey wrote: >> On Thu, Dec 23, 2010 at 8:44 AM, Luke Plant wrote: >> Perhaps it is not a problem when using bare asserts for this purpose, but I >> have grown to dislike asserts in testcases because they gi

Re: Using asserts in test code

2010-12-23 Thread Dave Smith
My team has adopted the convention of prepending "Sanity:" to the message of any assertion whose purpose is to verify that things are set up correctly for the 'main act' assertions. This helps us cut through the 'something is broken, but it's not here' noise when a change causes a bunch of tests t

Re: Using asserts in test code

2010-12-23 Thread Ian Clelland
On Thu, Dec 23, 2010 at 8:46 AM, Karen Tracey wrote: > On Thu, Dec 23, 2010 at 8:44 AM, Luke Plant wrote: > Perhaps it is not a problem when using bare asserts for this purpose, but I > have grown to dislike asserts in testcases because they give so little > information. For example, I am working

Re: Using asserts in test code

2010-12-23 Thread Karen Tracey
On Thu, Dec 23, 2010 at 8:44 AM, Luke Plant wrote: > Hi all, > > This is a question of test code style. > > In tests in my own projects, I use both the Python 'assert' statement > and the unittest TestCase.assert* methods, with the following > distinction: > > * The 'assert' statement is used to

Re: Using asserts in test code

2010-12-23 Thread Ian Clelland
On Thu, Dec 23, 2010 at 5:44 AM, Luke Plant wrote: > Hi all, > > This is a question of test code style. > > In tests in my own projects, I use both the Python 'assert' statement > and the unittest TestCase.assert* methods, with the following > distinction: > > * The 'assert' statement is used to m

Using asserts in test code

2010-12-23 Thread Luke Plant
Hi all, This is a question of test code style. In tests in my own projects, I use both the Python 'assert' statement and the unittest TestCase.assert* methods, with the following distinction: * The 'assert' statement is used to make assertions about the assumptions built in to *this* bit of code