[TIP] Fwd: running away from RSpec

Alfredo Deza alfredodeza at gmail.com
Sat Feb 12 13:20:25 PST 2011


Bah, forgot to include TiP in the reply.

---------- Forwarded message ----------
From: Alfredo Deza
Date: Sat, Feb 12, 2011 at 4:18 PM
Subject: Re: [TIP] running away from RSpec
To: "vanderson.mota"



On Sat, Feb 12, 2011 at 2:36 PM, vanderson.mota at gmail.com <
vanderson.mota at gmail.com> wrote:

> > Probably the most common (and understandable) answer is that Python
> syntax
> > wouldn't allow such a thing
> > whereas in Ruby it is possible.
>
> not syntax exactly. Rspec monkeypatches every object inside of its
> scope, inserting the methods "should" and "should_not". You can do
> something in python, but you can't monkeypatch the built-in types.
>
> If you want something like rspec, there is should_dsl.
> https://github.com/hugobr/should-dsl


I think that implementation is awful :(

Writing ``|should|`` doesn't look at all right to me.

>
>
> > This more of an open question I guess, but why there isn't a project in
> > Python that grabs the best features from RSpec
> > and implements them?
>
> I don't see a HUGE advantage in using "value.should be_true" instead
> of assertTrue(value). It's a matter of taste.
>
> The thing i like in Rspec is that you can have subcontexts in your
> tests/specs, like this:
>
> describe "login" do
>
>  ..code..
>
>   context "success" do
>     ....code...
>   end
>
>   context "failure" do
>     ...code...
>   end
> end
>
> It makes easier to keep your tests more organized. You can achieve
> such organization with unittest/unittest2, but will require a little
> more work.
> The only thing i would like in unittest is if the asserts were
> functions instead of methods. But this is a "nice-to-have". I can live
> with asserts as methods.
>
> Talking about the Rspec mocks:
>
> I don't like all that names... mocks, stubs... etc. I prefer to use
> mock.py, because it's much more simpler, IMHO.
>
> The only thing i think its a mistake is it to try to make a testing
> tool that looks like Ruby.


My intent was not to imply something like that, I'm more towards "if
language A is doing something
awesome for testing, why can't Python do/have something similar (better!)


> The better ports happen when you apply the
> most intention than implementation. The RSpec makes tests easier to
> write and maintain, in "ruby world". And works pretty well.
>
> Python have such projects, like nose, pytest, etc and they're doing
> quite a good job.
>
> py.test is absolutely awesome and is what I use day in and day out, but
this
is totally different from discussing the possibility of a Python RSpec
project/implementation.

>
> Which features you like in Rspec, despite teaching english to the
> interpreter? ;-p
>
>
> Cheers!
>
> 2011/2/12 Alfredo Deza <alfredodeza at gmail.com>
> > For the past few weeks I have been thinking a lot about RSpec and why
> there
> > is no clear, definite answer when
> > someone asks:
> >  "I'm looking for a Python equivalent of RSpec. Where can I find such a
> > thing?"
> > Probably the most common (and understandable) answer is that Python
> syntax
> > wouldn't allow such a thing
> > whereas in Ruby it is possible.
> > Ok, if that is so, then why there are so many projects (most of them
> already
> > un-maintained) that try to give
> > some RSpec features to Python?
> > There is Pinocchio written in part by Titus (last commit was in 2009),
> there
> > is a spec runner that Gary wrote, there is also
> > pyspec (last version from 2008) and a couple of others. I know there is
> > "lettuce" which tries to emulate Ruby's Cucumber
> > but that is not exactly RSpec.
> > So are we running away from RSpec just because we can't implement it in
> > Python? (or maybe we do want to implement it
> > and then we fail?).
> > This more of an open question I guess, but why there isn't a project in
> > Python that grabs the best features from RSpec
> > and implements them?
> > Isn't that how we came about UnitTesting? (e.g. "hey that's JUnit and
> seems
> > good let's implement that in Python")
> > Not trying to start a flamewar here, but I guess at some level it is
> healthy
> > to ask these kind of questions, specially since
> > a lot of the guys in this list are so important for the Python testing
> > environment.
> >
> >
> > _______________________________________________
> > testing-in-python mailing list
> > testing-in-python at lists.idyll.org
> > http://lists.idyll.org/listinfo/testing-in-python
> >
> >
>
>
>
> --
> Vanderson Mota dos Santos
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20110212/19ed85cf/attachment.htm>


More information about the testing-in-python mailing list