Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

TDD with nose or py.test

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


lacrima.maxim at gmail

Nov 30, 2009, 5:46 AM

Post #1 of 6 (395 views)
Permalink
TDD with nose or py.test

Hello!

I am learning TDD with Python and there is not much information about
this topic. Python is shipped with unittest module. That is fine, but
I also discovered other libraries: nose and py.test. They promise to
make life yet easier for a developer. But I still can't figure out,
which combination I should use them in.
Nose seems simpler than py.test, but py.test offers more features. And
both py.test and nose say that they do not replace unittest module,
but extend it.
So as I understand my choice should be nose + unittest, or py.test +
unittest.
And now I'd like to hear about best practices in TDD in Python. Maybe
not best practices, but basic approach.
So which tests should I write with unittest, which with nose or
py.test? How should I combine them?

I am learning Python and I need your advice.
Thanks in advance.

Sorry if my English isn't very proper
--
http://mail.python.org/mailman/listinfo/python-list


aahz at pythoncraft

Dec 5, 2009, 9:24 AM

Post #2 of 6 (362 views)
Permalink
Re: TDD with nose or py.test [In reply to]

In article <2519ffb0-fd49-4340-857b-62fca5c71421 [at] 33g2000vbe>,
Lacrima <lacrima.maxim [at] gmail> wrote:
>
>I am learning TDD with Python and there is not much information about
>this topic. Python is shipped with unittest module. That is fine, but
>I also discovered other libraries: nose and py.test. They promise to
>make life yet easier for a developer. But I still can't figure out,
>which combination I should use them in.

My company decided to use py.test because it offered better support for
cross-platform and multi-machine testing (at least as of a couple of
months ago when we made the decision). Otherwise, the two seem pretty
comparable and nose seems to be easier to use.
--
Aahz (aahz [at] pythoncraft) <*> http://www.pythoncraft.com/

The best way to get information on Usenet is not to ask a question, but
to post the wrong information.
--
http://mail.python.org/mailman/listinfo/python-list


roy at panix

Dec 5, 2009, 3:00 PM

Post #3 of 6 (362 views)
Permalink
Re: TDD with nose or py.test [In reply to]

In article
<2519ffb0-fd49-4340-857b-62fca5c71421 [at] 33g2000vbe>,
Lacrima <lacrima.maxim [at] gmail> wrote:

> Hello!
>
> I am learning TDD with Python and there is not much information about
> this topic. Python is shipped with unittest module. That is fine, but
> I also discovered other libraries: nose and py.test. They promise to
> make life yet easier for a developer. But I still can't figure out,
> which combination I should use them in.
> Nose seems simpler than py.test, but py.test offers more features. And
> both py.test and nose say that they do not replace unittest module,
> but extend it.
> So as I understand my choice should be nose + unittest, or py.test +
> unittest.
> And now I'd like to hear about best practices in TDD in Python. Maybe
> not best practices, but basic approach.
> So which tests should I write with unittest, which with nose or
> py.test? How should I combine them?

You're obsessing over details. Pick one and go with it. I've been using
unittest for years and I'm mostly happy with it. I've played with py.test
a bit, and while I like some features, I keep finding myself wandering back
to unittest. Maybe it's just what I know so I'm comfortable with it.

I've glanced at nose, but every time I look at it, I ask myself, "Do I want
to learn another testing tool, or do I just want to get on with testing the
code I'm writing now?", which inevitably brings me back to just sticking
with unittest.

I am very much a fan of TDD. Whenever I write a new class, here's the
first test I write:

class TestFoo(unitest.TestCase):
def test_construct(self):
foo = Foo()

If that passes, it means I've managed to create a new class, register it
with my build system (and, most likely, my source control system). In
keeping with the "write the very smallest amount of code you need to make
your test pass", my class will usually look like this at the point the
above test first passes:

class Foo:
pass

After that, it's all about adding features :-)
--
http://mail.python.org/mailman/listinfo/python-list


debatem1 at gmail

Dec 5, 2009, 3:25 PM

Post #4 of 6 (361 views)
Permalink
Re: TDD with nose or py.test [In reply to]

On Mon, Nov 30, 2009 at 8:46 AM, Lacrima <lacrima.maxim [at] gmail> wrote:
> Hello!
>
> I am learning TDD with Python and there is not much information about
> this topic. Python is shipped with unittest module. That is fine, but
> I also discovered other libraries: nose and py.test. They promise to
> make life yet easier for a developer. But I still can't figure out,
> which combination I should use them in.
> Nose seems simpler than py.test, but py.test offers more features. And
> both py.test and nose say that they do not replace unittest module,
> but extend it.
> So as I understand my choice should be nose + unittest, or py.test +
> unittest.
> And now I'd like to hear about best practices in TDD in Python. Maybe
> not best practices, but basic approach.
> So which tests should I write with unittest, which with nose or
> py.test? How should I combine them?
>
> I am learning Python and I need your advice.
> Thanks in advance.
>
> Sorry if my English isn't very proper

I use unittest, but mostly because its so close to junit and cppunit,
which I also use extensively. Having said that, it *is* in the standard
library and is a common denominator between all your options.

Geremy Condra
--
http://mail.python.org/mailman/listinfo/python-list


no.email at nospam

Dec 5, 2009, 3:37 PM

Post #5 of 6 (359 views)
Permalink
Re: TDD with nose or py.test [In reply to]

geremy condra <debatem1 [at] gmail> writes:
> I use unittest, but mostly because its so close to junit and cppunit,
> which I also use extensively. Having said that, it *is* in the standard
> library and is a common denominator between all your options.

What happened to doctest?
--
http://mail.python.org/mailman/listinfo/python-list


debatem1 at gmail

Dec 5, 2009, 9:04 PM

Post #6 of 6 (354 views)
Permalink
Re: TDD with nose or py.test [In reply to]

On Sat, Dec 5, 2009 at 6:37 PM, Paul Rubin <no.email [at] nospam> wrote:
> geremy condra <debatem1 [at] gmail> writes:
>> I use unittest, but mostly because its so close to junit and cppunit,
>> which I also use extensively. Having said that, it *is* in the standard
>> library and is a common denominator between all your options.
>
> What happened to doctest?

Worth mentioning as an option, I suppose, but at least for me
unittest fits the TDD workflow better. YMMV, of course.

Geremy Condra
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.