Re: Why i can't get the debug informations (in case of error) when i run LiveServerTestCase tests?

2013-02-09 Thread Harry P
I'm struggling with the same problem.  It's pretty annoying that you can't 
run a LiveServerTestCase with debug=True.  It makes it overly hard to do 
TDD at the beginning of a project, because you need to customise logging 
behaviour to get any kind of debugging working... 

hp (http://www.tdd-django-tutorial.com/)

On Wednesday, January 30, 2013 8:30:33 AM UTC, Alessandro Pelliciari wrote:
>
> Thanks for the answer!
>
> Because i'm developing and integrating some flow (social registration etc) 
> through tests.
>
> So, instead of creating every time a new user, creating a new social 
> association, and then after every try delete them from the database, the 
> test does it from me.
>
> So, its like a kind of dirty TDD with functional (selenium because i have 
> facebook login for example) testing.
>
>
> Anyway i think i can resolve with the 500 response logging the error to 
> the console, but it's my first project in Django (and python) so i can't 
> understand completely the way to logging at this moment.
>
>  
> Alessandro
>
>
> Il giorno mercoledì 30 gennaio 2013 03:18:46 UTC+1, Ramiro Morales ha 
> scritto:
>>
>> Ramiro Morales
>> On Jan 29, 2013 12:33 PM, "Alessandro Pelliciari"  
>> wrote:
>> >
>> > thanks for the link!
>> >
>> > So Isn't there a way to set DEBUG=True in tests?
>>
>> No. There isn't (at least with the built-in testing toolbox).
>>
>> Now, I'm trying to understand why do you rely in the debugging 500 
>> response contents on your tests. Do you screen scrap it to extract  
>> information about the origin of the failure?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Test driven development in Django framework

2012-09-07 Thread Harry P
Hey, glad to hear someone's been found it useful!

re: whether my unit tests are unit tests or not... some people have a very 
restrictive definition of what a unit test is - they want it to be 100% 
isolated from other tests, always mock out the filesystem and the database, 
etc.  That's fine, but we tend to find it's a bit OTT, and a slightly more 
relaxed approach is more productive.   Ultimately, I'm writing two types of 
test - some high-level tests that test the behaviour of the app from the 
user's point of view - so call them system tests, or functional tests, or 
acceptance tests, or whatever you will, but their purpose is to check the 
system actually works.  The other type of test is low-level, they test the 
behaviour of individual functions, classes etc, and their purpose is to 
help you think about your code before you write it, to think through edge 
cases and to help write correct code.

So, to me, the important thing is that you have those two types of test, 
and that they help you achieve those two different objectives.  Finer 
details of terminology or practices to do with mocking, stubbing etc are up 
to personal preferences really.

cheers,
hp



On Friday, September 7, 2012 10:25:32 AM UTC+1, jyria wrote:
>
> Thank you for reply,
>
> I have been using your tutorial to learn TDD in django. One of the best I 
> have found so far. You also talk about "unit tests" and thats what is 
> confusing. As I understand, your tutorial examples are not unit tests in 
> the strict meaning of the term. 
>
> You have a great tutorial and I have learned a lot of them. Maybe too much 
> focus on admin and polls app for me. I would have liked to see something 
> different and new. What about running you selenium functional tests in a 
> acceptance testing framework?
>
> I would love to see your tutorials for intermediate/advanced level.
>
> On Thursday, September 6, 2012 1:57:08 PM UTC+3, Harry P wrote:
>>
>> Hi there,
>>
>> I work for a bunch of XP fanatics, so we do quite religious TDD in our 
>> Python/Django development.   We start with functional/acceptance tests, 
>> which we write using Selenium, driving a real web browser, and following a 
>> test script that is essential a user story.  We then write unit tests that 
>> we can run using a python manage.py test.
>>
>> I've written a "TDD for beginners" tutorial, that covers both of these 
>> types of test:
>>
>> http://www.tdd-django-tutorial.com/
>>
>> I'd love any comments, feedback, suggestions?
>>
>> rgds,
>> Harry
>>
>> On Thursday, September 6, 2012 1:47:08 AM UTC+1, Mike Dewhirst wrote:
>>>
>>> On 6/09/2012 3:04am, Javier Guerra Giraldez wrote: 
>>> > On Wed, Sep 5, 2012 at 7:46 AM, jyria <jyr...@gmail.com> wrote: 
>>> >> What is your experience? Is it worth it, and is it possible? 
>>> >> 
>>> >> I tried it and found it quite difficult to follow guideline of unit 
>>> testing 
>>> >> -- testing a unit of code, a class for example. Maybe Im just 
>>> ignorant, but 
>>> >> I didnt see, how can I create registration app only with unit tests. 
>>> The 
>>> >> only way I could drive implementation with tests was using more like 
>>> an 
>>> >> integration testing approach: calling requests with data and 
>>> asserting that 
>>> >> new user was registered and that form was valid/invalid etc, but this 
>>> goes 
>>> >> against TDD as I understand it. So should I not worry about pure 
>>> "unit 
>>> >> testing" approach and use django client http request to validate 
>>> >> RegistrationForm. Or I should write unit tests for RegistrationForm 
>>> class? 
>>> > 
>>> > TDD is not unit-testing 
>>>
>>> Here is a lovely diagram I found recently - probably by following a link 
>>> someone posted here - which shows the TDD process with unit tests and 
>>> acceptance tests. 
>>>
>>> IMO it covers pretty much everything in the universe ... 
>>>
>>> http://www.methodsandtools.com/archive/attready3.jpg 
>>>
>>> > 
>>> > https://www.google.com/webhp?q=tdd%20is%20not%20unit%20testing 
>>> > 
>>> > 
>>> > in short, it's like you've found: the tests you easily get with TDD 
>>> > are more (but not exactly) like integration tests, because you test 
>>> > features, not units.  The "test isolated units" mantra of unit-testing 
>>> > requires different work.  There's nothing wrong in 

Re: Test driven development in Django framework

2012-09-06 Thread Harry P
Hi there,

I work for a bunch of XP fanatics, so we do quite religious TDD in our 
Python/Django development.   We start with functional/acceptance tests, 
which we write using Selenium, driving a real web browser, and following a 
test script that is essential a user story.  We then write unit tests that 
we can run using a python manage.py test.

I've written a "TDD for beginners" tutorial, that covers both of these 
types of test:

http://www.tdd-django-tutorial.com/

I'd love any comments, feedback, suggestions?

rgds,
Harry

On Thursday, September 6, 2012 1:47:08 AM UTC+1, Mike Dewhirst wrote:
>
> On 6/09/2012 3:04am, Javier Guerra Giraldez wrote: 
> > On Wed, Sep 5, 2012 at 7:46 AM, jyria  
> wrote: 
> >> What is your experience? Is it worth it, and is it possible? 
> >> 
> >> I tried it and found it quite difficult to follow guideline of unit 
> testing 
> >> -- testing a unit of code, a class for example. Maybe Im just ignorant, 
> but 
> >> I didnt see, how can I create registration app only with unit tests. 
> The 
> >> only way I could drive implementation with tests was using more like an 
> >> integration testing approach: calling requests with data and asserting 
> that 
> >> new user was registered and that form was valid/invalid etc, but this 
> goes 
> >> against TDD as I understand it. So should I not worry about pure "unit 
> >> testing" approach and use django client http request to validate 
> >> RegistrationForm. Or I should write unit tests for RegistrationForm 
> class? 
> > 
> > TDD is not unit-testing 
>
> Here is a lovely diagram I found recently - probably by following a link 
> someone posted here - which shows the TDD process with unit tests and 
> acceptance tests. 
>
> IMO it covers pretty much everything in the universe ... 
>
> http://www.methodsandtools.com/archive/attready3.jpg 
>
> > 
> > https://www.google.com/webhp?q=tdd%20is%20not%20unit%20testing 
> > 
> > 
> > in short, it's like you've found: the tests you easily get with TDD 
> > are more (but not exactly) like integration tests, because you test 
> > features, not units.  The "test isolated units" mantra of unit-testing 
> > requires different work.  There's nothing wrong in adding 'real' 
> > unit-tests, but it's not required to do effective TDD. 
> > 
> > I guess that since unittesting became so well known so long ago, 
> > almost all test frameworks (including Python's and Django's) call 
> > their base test class "UnitTest", but they're not; they're just tests. 
> >   you make them feature tests, or integration tests, or unit tests, or 
> > whatever kind of test. 
> > 
> > now, about the pros/cons of unit-testing vs. other kinds of tests. 
> > that's a whole debate that i'm not going to touch. 
> > 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/zN3GT06MfH4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.