Re: [flask] Benefits of Flask-Testing
- From:
- Giovanni Giorgi
- Date:
- 2011-07-05 @ 14:40
hi,
my 2-cents on unit testing, and some important insights...
A very easy way to check your architecture is trying to write unit tests
on it. For instance if class Card Deck has a shuffle() method, you
must be able to create a Card Deck of predefined size (i.e. 5 cards
1,2,3,4,5), call shuffle and verify in an easy way the result(i.d.
1,4,2,5,3)
You must be able to do it without instantiating the entire project
classes, and the test must be very clean to read.
If you cannot do it, you must add layers between classes, restructure
them, until you get an easy way to do it.
Then reiterate this step for all the core classes of your project.
So you can also use TDD to _drive_ your code, not only to "bullet-proof
it" :)
On Tue, July 5, 2011 4:28 pm, Alessio Civitillo wrote:
> Smartboy, that was really useful for me. I was struggling with the whole
> concept of testing. It is a pity there is not so much documentation on
> this
> matter for python.
>
> On Tue, Jul 5, 2011 at 12:04 PM, Smartboy <smartboyathome@gmail.com>
> wrote:
>
>> Good question. :)
>>
>> One of the benefits of test-driven development in general is it
>> actually helps keep your code stable as you add more and more
>> features. Basically, when you implement a function in your model, you
>> create a test for it so that later when you're adding a big feature,
>> you can just run the tests to see what, if anything, you broke.
>>
>> In addition, test-driven development also keeps your code modular by
>> forcing you to decouple your model from your view logic in order to
>> test it. This leads to cleaner code and longer lasting
>> maintainability.
>>
>> For example, I've been working on a library along with a fellow intern
>> at my company, and our job is to create a web interface for it in
>> ASP.NET MVC 3. One of the first things we did was refactor so that it
>> was a lot more modular, and then we wrote tests for each one of our
>> models, forcing us to refactor further. We may have lost time due to
>> all the refactoring, but what we gained out of it is a much cleaner
>> and clearer code base.
>>
>> I don't know if there are any Python books on the subject, but I
>> personally recommend Robert C. Martin's "Clean Code: A Handbook of
>> Agile Software Craftsmanship". It doesn't use too much C# beyond basic
>> function-class examples in order to show monolithic code and modular
>> code as one progresses through the book.
>>
>> Smartboy
>>
>> On Tue, Jul 5, 2011 at 3:17 AM, Alex <thinkpragmatic@gmail.com> wrote:
>> > Hi all.
>> >
>> > I'm writing my first tests for a simple Flask web application.
>> > I've read both Flask and Flask-Testing docs, but I'm wondering which
>> > are the benefits of using Flask-Testing. Could anyone provide an
>> > example?
>> >
>> > Thank you!
>> >
>> > Alex
>> >
>>
>
>
>
> --
> Regards,
> ------------------------------------
> Alessio Civitillo
> alessiocivitillo@gmail.com
> Mobile: (0045) 52645608
> Linkedin: http://it.linkedin.com/in/alessiocivitillo
>
--
Senior Consultant
http://gioorgi.com
Re: [flask] Benefits of Flask-Testing
- From:
- Jesaja Everling
- Date:
- 2011-07-05 @ 14:39
There is a book on Python that has a section about testing and TDD:
"Foundations of Agile Python Development".
I have to admit that i never got around to read it to the end, but
from what i have read it seems to give a lot of good advice.
It shows how to work with tools like setuptools, buildbot and nose,
but i think even if you use a different toolchain you will find a lot
to consider in it.
Best Regards,
Jesaja Everling
On Tue, Jul 5, 2011 at 4:28 PM, Alessio Civitillo
<alessiocivitillo@gmail.com> wrote:
> Smartboy, that was really useful for me. I was struggling with the whole
> concept of testing. It is a pity there is not so much documentation on this
> matter for python.
>
> On Tue, Jul 5, 2011 at 12:04 PM, Smartboy <smartboyathome@gmail.com> wrote:
>>
>> Good question. :)
>>
>> One of the benefits of test-driven development in general is it
>> actually helps keep your code stable as you add more and more
>> features. Basically, when you implement a function in your model, you
>> create a test for it so that later when you're adding a big feature,
>> you can just run the tests to see what, if anything, you broke.
>>
>> In addition, test-driven development also keeps your code modular by
>> forcing you to decouple your model from your view logic in order to
>> test it. This leads to cleaner code and longer lasting
>> maintainability.
>>
>> For example, I've been working on a library along with a fellow intern
>> at my company, and our job is to create a web interface for it in
>> ASP.NET MVC 3. One of the first things we did was refactor so that it
>> was a lot more modular, and then we wrote tests for each one of our
>> models, forcing us to refactor further. We may have lost time due to
>> all the refactoring, but what we gained out of it is a much cleaner
>> and clearer code base.
>>
>> I don't know if there are any Python books on the subject, but I
>> personally recommend Robert C. Martin's "Clean Code: A Handbook of
>> Agile Software Craftsmanship". It doesn't use too much C# beyond basic
>> function-class examples in order to show monolithic code and modular
>> code as one progresses through the book.
>>
>> Smartboy
>>
>> On Tue, Jul 5, 2011 at 3:17 AM, Alex <thinkpragmatic@gmail.com> wrote:
>> > Hi all.
>> >
>> > I'm writing my first tests for a simple Flask web application.
>> > I've read both Flask and Flask-Testing docs, but I'm wondering which
>> > are the benefits of using Flask-Testing. Could anyone provide an
>> > example?
>> >
>> > Thank you!
>> >
>> > Alex
>> >
>
>
>
> --
> Regards,
> ------------------------------------
> Alessio Civitillo
> alessiocivitillo@gmail.com
> Mobile: (0045) 52645608
> Linkedin: http://it.linkedin.com/in/alessiocivitillo
>
Re: [flask] Benefits of Flask-Testing
- From:
- Dustin Chapman
- Date:
- 2011-07-05 @ 15:14
Alessio:
There is another book called "Python Testing: Beginner's Guide" by
Daniel Arbuckle [1], which does not discuss how to deploy your
program/app, but gives you a rather good feel for TDD in Python. One
section is an overview of Twill [2], which may be useful for testing
your web apps.
-Dustin
[1] http://www.amazon.com/s/field-keywords=1847198848
[2] http://pypi.python.org/pypi/twill
On Tue, Jul 5, 2011 at 10:39 AM, Jesaja Everling <jeverling@gmail.com> wrote:
> There is a book on Python that has a section about testing and TDD:
> "Foundations of Agile Python Development".
> I have to admit that i never got around to read it to the end, but
> from what i have read it seems to give a lot of good advice.
> It shows how to work with tools like setuptools, buildbot and nose,
> but i think even if you use a different toolchain you will find a lot
> to consider in it.
>
> Best Regards,
>
> Jesaja Everling
>
>
Re: [flask] Benefits of Flask-Testing
- From:
- Alessio Civitillo
- Date:
- 2011-07-05 @ 18:39
Thanks guys.
Dustin, but Twill is still in development?
On 7/5/11, Dustin Chapman <dustin.r.chapman@gmail.com> wrote:
> Alessio:
>
> There is another book called "Python Testing: Beginner's Guide" by
> Daniel Arbuckle [1], which does not discuss how to deploy your
> program/app, but gives you a rather good feel for TDD in Python. One
> section is an overview of Twill [2], which may be useful for testing
> your web apps.
>
> -Dustin
>
> [1] http://www.amazon.com/s/field-keywords=1847198848
> [2] http://pypi.python.org/pypi/twill
>
>
>
> On Tue, Jul 5, 2011 at 10:39 AM, Jesaja Everling <jeverling@gmail.com>
> wrote:
>> There is a book on Python that has a section about testing and TDD:
>> "Foundations of Agile Python Development".
>> I have to admit that i never got around to read it to the end, but
>> from what i have read it seems to give a lot of good advice.
>> It shows how to work with tools like setuptools, buildbot and nose,
>> but i think even if you use a different toolchain you will find a lot
>> to consider in it.
>>
>> Best Regards,
>>
>> Jesaja Everling
>>
>>
>
--
Regards,
------------------------------------
Alessio Civitillo
alessiocivitillo@gmail.com
Mobile: (0045) 52645608
Linkedin: http://it.linkedin.com/in/alessiocivitillo
Re: [flask] Benefits of Flask-Testing
- From:
- Dustin Chapman
- Date:
- 2011-07-05 @ 20:33
> Dustin, but Twill is still in development?
I know the PyPI page says beta, but I think those that use it will not
claim any issues with it.
-Dustin
Re: [flask] Benefits of Flask-Testing
- From:
- Alessio Civitillo
- Date:
- 2011-07-06 @ 07:25
From http://twill.idyll.org/:
The latest release of twill is twill
0.9<http://twill.idyll.org/ANNOUNCE-0.9.txt>,
released Thursday, December 27th, *2007*
That kind of moved me away from twill, I like the idea although.
On Tue, Jul 5, 2011 at 10:33 PM, Dustin Chapman
<dustin.r.chapman@gmail.com>wrote:
> > Dustin, but Twill is still in development?
>
> I know the PyPI page says beta, but I think those that use it will not
> claim any issues with it.
>
> -Dustin
>
--
Regards,
------------------------------------
Alessio Civitillo
alessiocivitillo@gmail.com
Mobile: (0045) 52645608
Linkedin: http://it.linkedin.com/in/alessiocivitillo
Re: [flask] Benefits of Flask-Testing
- From:
- Dustin Chapman
- Date:
- 2011-07-06 @ 11:29
On Wed, Jul 6, 2011 at 3:25 AM, Alessio Civitillo
<alessiocivitillo@gmail.com> wrote:
> >From http://twill.idyll.org/:
>
> The latest release of twill is twill 0.9, released Thursday, December 27th,
> 2007
>
> That kind of moved me away from twill, I like the idea although.
Do you have a recommended alternative to Twill?
Re: [flask] Benefits of Flask-Testing
- From:
- Kamal Gill
- Date:
- 2011-07-06 @ 18:17
FunkLoad is a viable alternative and appears to be in active development.
http://pypi.python.org/pypi/funkload/
HTH,
Kamal
On Jul 6, 2011, at 4:29 AM, Dustin Chapman wrote:
> On Wed, Jul 6, 2011 at 3:25 AM, Alessio Civitillo
> <alessiocivitillo@gmail.com> wrote:
>>> From http://twill.idyll.org/:
>>
>> The latest release of twill is twill 0.9, released Thursday, December 27th,
>> 2007
>>
>> That kind of moved me away from twill, I like the idea although.
>
>
> Do you have a recommended alternative to Twill?
Re: [flask] Benefits of Flask-Testing
- From:
- Jesaja Everling
- Date:
- 2011-07-06 @ 11:43
I wouldn't be too concerned about the release date of twill, I guess
there just was no need to release updated versions.
AFAK twill is used a lot, and it seems it does what it's supposed to do.
I don't know of any direct alternative, but the twill website lists a
few other projects:
http://twill.idyll.org/other.html
Twill is built on mechanize, so if you don't want to rely on twill you
could use mechanize itself for testing. It seems to be actively
maintained:
https://github.com/jjlee/mechanize
Best Regards,
Jesaja Everling
On Wed, Jul 6, 2011 at 1:29 PM, Dustin Chapman
<dustin.r.chapman@gmail.com> wrote:
> On Wed, Jul 6, 2011 at 3:25 AM, Alessio Civitillo
> <alessiocivitillo@gmail.com> wrote:
>> >From http://twill.idyll.org/:
>>
>> The latest release of twill is twill 0.9, released Thursday, December 27th,
>> 2007
>>
>> That kind of moved me away from twill, I like the idea although.
>
>
> Do you have a recommended alternative to Twill?
>