R. David Murray <rdmur...@bitdance.com> added the comment:

Your code is fine (though to my tastes a bit verbose...if it were me I'd just 
put the code in the setUp and tearDown methods and hardcode 'COLUMNS' (it isn't 
like the name COLUMNS is going to change)...but that's just personal style).

The EnviormentVarGuard version would look like this (untested):

   def setUp(self):
       self.guard = EnvironmentVarGuard()
       self.environ = self.guard.__enter__()
       # Current tests expect 80 column terminal width.
       self.environ['COLUMNS'] = 80

   def tearDown(self):
       self.guard.__exit__(None, None, None)

You could of course delete COLUMNS as you did, but I thought setting it to 80 
would be more explicit.

Another comment about the patch: by inspection it appears that adding setUp and 
tearDown to TestCase isn't enough, since subclasses and mixins define those 
without calling the superclass versions.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9553>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to