[MERGE] Before actually using encoding need to check that Python has corresponding codec (v.2)
John Arbash Meinel
john at arbash-meinel.com
Tue Jan 2 17:24:19 GMT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Aaron Bentley wrote:
> Alexander Belchenko wrote:
>> Yes, I did. I copy approach of John Meinel from TestTerminalEncoding
>> where instead of self.tearDown() method is used
> Ah. I missed it because I looked at the wrong _reset.
>> I should admit that I don't completely understand difference between
>> .tearDown and ._reset, but I think it's related to problems with
>> test cleanup when error in test raised.
> We use addCleanup rather than extending tearDown, but I don't remember
> the rationale. _reset isn't a special name, it's the use of addCleanup
> that makes it special.
We use addCleanup because if you override tearDown() it is easy to
forget to call the super classes tearDown() and then the test stops
cleaning up after itself. You notice if setUp() isn't called, because
then the test fails, but if you forget tearDown(), then it just doesn't
clean up log files, etc.
This was actually Martin's recommendation.
As far as 'self._reset()' goes, I usually create a local function
foo = self.create_foo()
# do cleanup here
I've called it reset() or cleanup().
In this case, I think I'm using a member function because I'm using
member variables to save the original state. I think we could just as
orig_stdin = sys.stdin
sys.stdin = orig_stdin
I'm not sure which is more obvious, but I kind of like the local
function because it keeps everything together.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the bazaar