diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py index 4582fa7ae82..9b52659b1fa 100644 --- a/Lib/test/test_optparse.py +++ b/Lib/test/test_optparse.py @@ -1500,8 +1500,16 @@ class TestHelp(BaseTest): self.assertHelpEquals(_expected_help_long_opts_first) def test_help_title_formatter(self): - self.parser.formatter = TitledHelpFormatter() - self.assertHelpEquals(_expected_help_title_formatter) + save = os.environ.get("COLUMNS") + try: + os.environ["COLUMNS"] = "80" + self.parser.formatter = TitledHelpFormatter() + self.assertHelpEquals(_expected_help_title_formatter) + finally: + if save is not None: + os.environ["COLUMNS"] = save + else: + del os.environ["COLUMNS"] def test_wrap_columns(self): # Ensure that wrapping respects $COLUMNS environment variable.