diff options
author | Jiri Podivin <jpodivin@redhat.com> | 2022-10-26 14:02:07 +0200 |
---|---|---|
committer | Jiri Podivin <jpodivin@redhat.com> | 2023-03-01 09:18:15 +0100 |
commit | 72e81d7d846a8e306fd8d98e2f15270a8a537620 (patch) | |
tree | 133d0f4b98c992e0a265952a502bd2720dffb2b7 /cliff/tests/test_utils.py | |
parent | fb9a3a9b2daa21317d0adceca86215c393e975e6 (diff) | |
download | cliff-master.tar.gz |
Functions used for deriving terminal width are no longer
necessary, as Python 3.3 introduced[0] built in solution.
Remaining helper function `utils.terminal_width` received docstring
explaining return parameters.
Method `_assign_max_widths` of the `TableFormatter` class was refactored
to no longer use the `stdout` argument. Uses of the method were adjusted accordingly.
Method now also has minimal docstring. Minor adjustment was made to inline comments
to more closely reflect functionality of the code.
[0]https://docs.python.org/3.8/library/os.html?highlight=get_terminal_size#os.get_terminal_size
Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I2898f099227e8c97aef6492c60f2f99038aa1357
Diffstat (limited to 'cliff/tests/test_utils.py')
-rw-r--r-- | cliff/tests/test_utils.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/cliff/tests/test_utils.py b/cliff/tests/test_utils.py index 3699a75..7650d78 100644 --- a/cliff/tests/test_utils.py +++ b/cliff/tests/test_utils.py @@ -13,7 +13,6 @@ # under the License. import os -import sys from unittest import mock from cliff.tests import base @@ -23,7 +22,7 @@ from cliff import utils class TestTerminalWidth(base.TestBase): def test(self): - width = utils.terminal_width(sys.stdout) + width = utils.terminal_width() # Results are specific to the execution environment, so only assert # that no error is raised. if width is not None: @@ -33,8 +32,8 @@ class TestTerminalWidth(base.TestBase): def test_get_terminal_size(self, mock_os): ts = os.terminal_size((10, 5)) mock_os.get_terminal_size.return_value = ts - width = utils.terminal_width(sys.stdout) + width = utils.terminal_width() self.assertEqual(10, width) mock_os.get_terminal_size.side_effect = OSError() - width = utils.terminal_width(sys.stdout) + width = utils.terminal_width() self.assertIs(None, width) |