class_docstr: A pytest class suite for gpustat.
class_docstr_tok: ["A","pytest","class","suite","for","gpustat","."]
code: def test_args_commandline_width(self, scenario_basic):
      capture_output = self.capture_output
  
      # see MOCK_EXPECTED_OUTPUT_DEFAULT
      assert len("GeForce GTX TITAN 0") == 19
  
      s = capture_output("gpustat", "--gpuname-width", "25")
      print("- Should have width=25")
      print(s)
      assert "GeForce GTX TITAN 0       |" in remove_ansi_codes(s)
      assert "GeForce RTX 2             |" in remove_ansi_codes(s)
      #                         ^012345
      #                        19
  
      # See #47 (since v1.0)
      print("- Should have width=10 (with truncation)")
      s = capture_output("gpustat", "--gpuname-width", "10")
      print(s)
      assert "…X TITAN 0 |" in remove_ansi_codes(s)
      assert "…rce RTX 2 |" in remove_ansi_codes(s)
      #       1234567890
  
      print("- Should have width=1 (too short)")
      s = capture_output("gpustat", "--gpuname-width", "1")
      print(s)
      assert "… |" in remove_ansi_codes(s)
  
      print("- Should have width=0: no name displayed.")
      s = capture_output("gpustat", "--gpuname-width", "0")
      print(s)
      assert "[0]  80°C" in remove_ansi_codes(s)
  
      print("- Invalid inputs")
      with pytest.raises(AssertionError, match="Argparse failed"):
          s = capture_output("gpustat", "--gpuname-width", "-1")
      with pytest.raises(AssertionError, match="Argparse failed"):
          s = capture_output("gpustat", "--gpuname-width", "None")
  
imports: import ctypes
  import os
  import re
  import shlex
  import sys
  import types
  from collections import namedtuple
  from io import StringIO
  from typing import Any
  import psutil
  import pytest
  from mockito import ANY, mock, unstub, when, when2
  import gpustat
  from gpustat.nvml import pynvml, pynvml_monkeypatch
label_desc: Use image node_id 10 for calling the TestGPUStat obj's underlying member method code with example usage: obj.test_args_commandline_width(scenario_basic) without return types