[issue9553] test_argparse.py: 80 failures if COLUMNS env var set to a value other than 80

R. David Murray report at bugs.python.org
Wed Aug 11 17:06:14 CEST 2010


R. David Murray <rdmurray at 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 <report at bugs.python.org>
<http://bugs.python.org/issue9553>
_______________________________________


More information about the Python-bugs-list mailing list