@@ -519,6 +519,47 @@ def test_default_thing_input_out_of_range(self, monkeypatch):
519519
520520 assert result == "foo"
521521
522+ def test_default_thing_spacing (self , monkeypatch ):
523+ stdout_buf = io .StringIO ()
524+ monkeypatch .setattr ("sys.stdin" , io .StringIO ("1\n " ))
525+
526+ with contextlib .redirect_stdout (stdout_buf ):
527+ _default_thing_input (
528+ "foo\n " , [* range (1 , 10_001 )], "prompt text" , "error text"
529+ )
530+
531+ output_lines = stdout_buf .getvalue ().splitlines ()
532+
533+ assert output_lines [3 ] == " 1 - 1"
534+ assert output_lines [11 ] == " 9 - 9"
535+ assert output_lines [12 ] == " 10 - 10"
536+ assert output_lines [101 ] == " 99 - 99"
537+ assert output_lines [102 ] == " 100 - 100"
538+ assert output_lines [1001 ] == " 999 - 999"
539+ assert output_lines [1002 ] == " 1000 - 1000"
540+ assert output_lines [10_001 ] == " 9999 - 9999"
541+ assert output_lines [10_002 ] == " 10000 - 10000"
542+
543+ def test_default_thing_spacing_with_current (self , monkeypatch ):
544+ stdout_buf = io .StringIO ()
545+ monkeypatch .setattr ("sys.stdin" , io .StringIO ("1\n " ))
546+
547+ with contextlib .redirect_stdout (stdout_buf ):
548+ _default_thing_input (
549+ "foo\n " ,
550+ [* range (1 , 10 )],
551+ "prompt text" ,
552+ "error text" ,
553+ current_value = "foo" ,
554+ )
555+
556+ output_lines = stdout_buf .getvalue ().splitlines ()
557+
558+ print (output_lines )
559+ assert output_lines [4 ] == " 2 - 1"
560+ assert output_lines [11 ] == " 9 - 8"
561+ assert output_lines [12 ] == " 10 - 9"
562+
522563 def test_default_text_input_optional (self , monkeypatch ):
523564 # No value specified
524565 stdout_buf = io .StringIO ()
0 commit comments