<meta charset="utf-8">Bah, forgot to include TiP in the reply.<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Alfredo Deza</b> <br>Date: Sat, Feb 12, 2011 at 4:18 PM<br>
Subject: Re: [TIP] running away from RSpec<br>To: "vanderson.mota"<br><br><br><br><div class="gmail_quote"><div class="im">On Sat, Feb 12, 2011 at 2:36 PM, <a href="mailto:vanderson.mota@gmail.com" target="_blank">vanderson.mota@gmail.com</a> <span dir="ltr"><<a href="mailto:vanderson.mota@gmail.com" target="_blank">vanderson.mota@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>> Probably the most common (and understandable) answer is that Python syntax<br>
> wouldn't allow such a thing<br>
> whereas in Ruby it is possible.<br>
<br>
</div>not syntax exactly. Rspec monkeypatches every object inside of its<br>
scope, inserting the methods "should" and "should_not". You can do<br>
something in python, but you can't monkeypatch the built-in types.<br>
<br>
If you want something like rspec, there is should_dsl.<br>
<a href="https://github.com/hugobr/should-dsl" target="_blank">https://github.com/hugobr/should-dsl</a></blockquote><div><br></div></div><div>I think that implementation is awful :(</div><div><br></div><div>Writing ``|should|`` doesn't look at all right to me. </div>
<div><div></div><div class="h5">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<div><br>
> This more of an open question I guess, but why there isn't a project in<br>
> Python that grabs the best features from RSpec<br>
> and implements them?<br>
<br>
</div>I don't see a HUGE advantage in using "value.should be_true" instead<br>
of assertTrue(value). It's a matter of taste.<br>
<br>
The thing i like in Rspec is that you can have subcontexts in your<br>
tests/specs, like this:<br>
<br>
describe "login" do<br>
<br>
..code..<br>
<br>
context "success" do<br>
....code...<br>
end<br>
<br>
context "failure" do<br>
...code...<br>
end<br>
end<br>
<br>
It makes easier to keep your tests more organized. You can achieve<br>
such organization with unittest/unittest2, but will require a little<br>
more work.<br>
The only thing i would like in unittest is if the asserts were<br>
functions instead of methods. But this is a "nice-to-have". I can live<br>
with asserts as methods.<br>
<br>
Talking about the Rspec mocks:<br>
<br>
I don't like all that names... mocks, stubs... etc. I prefer to use<br>
mock.py, because it's much more simpler, IMHO.<br>
<br>
The only thing i think its a mistake is it to try to make a testing<br>
tool that looks like Ruby. </blockquote><div><br></div></div></div><div>My intent was not to imply something like that, I'm more towards "if language A is doing something</div><div>awesome for testing, why can't Python do/have something similar (better!)</div>
<div class="im">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The better ports happen when you apply the<br>
most intention than implementation. The RSpec makes tests easier to<br>
write and maintain, in "ruby world". And works pretty well.<br>
<br>
Python have such projects, like nose, pytest, etc and they're doing<br>
quite a good job.<br>
<br></blockquote></div><div>py.test is absolutely awesome and is what I use day in and day out, but this</div><div>is totally different from discussing the possibility of a Python RSpec project/implementation. </div><div>
<div></div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Which features you like in Rspec, despite teaching english to the<br>
interpreter? ;-p<br>
<br>
<br>
Cheers!<br>
<br>
2011/2/12 Alfredo Deza <<a href="mailto:alfredodeza@gmail.com" target="_blank">alfredodeza@gmail.com</a>><br>
<div><div></div><div>> For the past few weeks I have been thinking a lot about RSpec and why there<br>
> is no clear, definite answer when<br>
> someone asks:<br>
> "I'm looking for a Python equivalent of RSpec. Where can I find such a<br>
> thing?"<br>
> Probably the most common (and understandable) answer is that Python syntax<br>
> wouldn't allow such a thing<br>
> whereas in Ruby it is possible.<br>
> Ok, if that is so, then why there are so many projects (most of them already<br>
> un-maintained) that try to give<br>
> some RSpec features to Python?<br>
> There is Pinocchio written in part by Titus (last commit was in 2009), there<br>
> is a spec runner that Gary wrote, there is also<br>
> pyspec (last version from 2008) and a couple of others. I know there is<br>
> "lettuce" which tries to emulate Ruby's Cucumber<br>
> but that is not exactly RSpec.<br>
> So are we running away from RSpec just because we can't implement it in<br>
> Python? (or maybe we do want to implement it<br>
> and then we fail?).<br>
> This more of an open question I guess, but why there isn't a project in<br>
> Python that grabs the best features from RSpec<br>
> and implements them?<br>
> Isn't that how we came about UnitTesting? (e.g. "hey that's JUnit and seems<br>
> good let's implement that in Python")<br>
> Not trying to start a flamewar here, but I guess at some level it is healthy<br>
> to ask these kind of questions, specially since<br>
> a lot of the guys in this list are so important for the Python testing<br>
> environment.<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> testing-in-python mailing list<br>
> <a href="mailto:testing-in-python@lists.idyll.org" target="_blank">testing-in-python@lists.idyll.org</a><br>
> <a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
><br>
><br>
<font color="#888888"><br>
<br>
<br>
--<br>
Vanderson Mota dos Santos<br>
</font></blockquote></div></div></div><br>
</div><br>