1#! /usr/bin/python3 2 3import pexpect 4import unittest 5import re 6import os 7import subprocess 8import signal 9import time 10 11keytab = { 12 "<home>": "\033[1~", 13 "<s-home>": "\033[1;2H", 14 "<c-home>": "\033[1;5H", 15 "<end>": "\033[4~", 16 "<s-end>": "\033[1;2F", 17 "<c-end>": "\033[1;5F", 18 "<ins>": "\033[2~", 19 "<s-ins>": "\033[2;2~", 20 "<c-ins>": "\033[2;5~", 21 "<del>": "\033[3~", 22 "<s-del>": "\033[3;2~", 23 "<c-del>": "\033[3;5~", 24 "<pgup>": "\033[5~", 25 "<c-pgup>": "\033[5;5~", 26 "<pgdown>": "\033[6~", 27 "<c-pgdown>": "\033[6;5~", 28 "<backspace>": "", 29 "<tab>": "\t", 30 "<cr>": "\r", 31 "<lf>": "\n", 32 "<left>": "\033[D", 33 "<s-left>": "\033[1;2D", 34 "<aleft>": "\033OD", 35 "<right>": "\033[C", 36 "<s-right>": "\033[1;2C", 37 "<aright>": "\033OC", 38 "<up>": "\033[A", 39 "<s-up>": "\033[1;2A", 40 "<aup>": "\033OA", 41 "<down>": "\033[B", 42 "<s-down>": "\033[1;2B", 43 "<adown>": "\033OB", 44 "<c-left>": "\033[1;5D", 45 "<c-right>": "\033[1;5C", 46 "<c-up>": "\033[1;5A", 47 "<c-down>": "\033[1;5B", 48 "<m-left>": "\033[1;3D", 49 "<m-right>": "\033[1;3C", 50 "<m-up>": "\033[1;3A", 51 "<m-down>": "\033[1;3B", 52 "<c-a>": "", 53 "<c-b>": "", 54 "<c-c>": "", 55 "<c-d>": "", 56 "<c-e>": "", 57 "<c-f>": "", 58 "<c-k>": "", 59 "<c-l>": "", 60 "<c-n>": "", 61 "<c-p>": "", 62 "<c-r>": "", 63 "<c-s>": "", 64 "<c-t>": "", 65 "<c-u>": "", 66 "<c-v>": "", 67 "<c-w>": "", 68 "<c-y>": "", 69 "<c-z>": "", 70 "<m-b>": "\033b", 71 "<m-c>": "\033c", 72 "<m-d>": "\033d", 73 "<m-f>": "\033f", 74 "<m-l>": "\033l", 75 "<m-n>": "\033n", 76 "<m-p>": "\033p", 77 "<m-u>": "\033u", 78 "<m-y>": "\033y", 79 "<m-.>": "\033.", 80 "<m-backspace>": "\033\177", 81 "<f1>": "\033OP", 82 "<f2>": "\033OQ", 83 "<f3>": "\033OR", 84 "<f4>": "\033OS", 85 "<f5>": "\033[15~", 86 "<f6>": "\033[17~", 87 "<f7>": "\033[18~", 88 "<f8>": "\033[19~", 89 "<f9>": "\033[20~", 90 "<f10>": "\033[21~", 91 "<f11>": "\033[23~", 92 "<f12>": "\033[24~", 93 "<s-f1>": "\033[1;2P", 94 "<s-f2>": "\033[1;2Q", 95 "<s-f3>": "\033[1;2R", 96 "<s-f4>": "\033[1;2S", 97 "<s-f5>": "\033[15;2~", 98 "<s-f6>": "\033[17;2~", 99 "<s-f7>": "\033[18;2~", 100 "<s-f8>": "\033[19;2~", 101 "<s-f9>": "\033[20;2~", 102 "<s-f10>": "\033[21;2~", 103 "<s-f11>": "\033[23;2~", 104 "<s-f12>": "\033[24;2~", 105 "<c-f1>": "\033[1;5P", 106 "<c-f2>": "\033[1;5Q", 107 "<c-f3>": "\033[1;5R", 108 "<c-f4>": "\033[1;5S", 109 "<c-f5>": "\033[15;5~", 110 "<c-f6>": "\033[17;5~", 111 "<c-f7>": "\033[18;5~", 112 "<c-f8>": "\033[19;5~", 113 "<c-f9>": "\033[20;5~", 114 "<c-f10>": "\033[21;5~", 115 "<c-f11>": "\033[23;5~", 116 "<c-f12>": "\033[24;5~", 117 "<s-tab>": "\033[Z", 118 "<paste-pfx>": "\033[200~", 119 "<paste-sfx>": "\033[201~" 120} 121 122termseq = { 123 "\x1bc": "<RIS>", 124 "\x1b[0m": "<rst>", 125 "\x1b[H": "<mvhm>", 126 "\x1b[2J": "<clr>", 127 "\x1b[J": "<ceos>", 128 "\x1b[0;22;30m": "<black>", 129 "\x1b[0;22;31m": "<red>", 130 "\x1b[0;22;32m": "<green>", 131 "\x1b[0;22;33m": "<brown>", 132 "\x1b[0;22;34m": "<blue>", 133 "\x1b[0;22;35m": "<magenta>", 134 "\x1b[0;22;36m": "<cyan>", 135 "\x1b[0;22;37m": "<lightgray>", 136 "\x1b[0;1;30m": "<gray>", 137 "\x1b[0;1;31m": "<brightred>", 138 "\x1b[0;1;32m": "<brightgreen>", 139 "\x1b[0;1;33m": "<yellow>", 140 "\x1b[0;1;34m": "<brightblue>", 141 "\x1b[0;1;35m": "<brightmagenta>", 142 "\x1b[0;1;36m": "<brightcyan>", 143 "\x1b[0;1;37m": "<white>", 144 "\x1b[1;32m": "<brightgreen>", 145 "\x1b[101;1;33m": "<err>", 146 "\x07": "<bell>", 147 "\x1b[2~": "<ins-key>", 148 "\x1b[?2004h": "<paste-on>", 149 "\x1b[?2004l": "<paste-off>" 150} 151colRe = re.compile( "\\x1b\\[(\\d+)G" ) 152upRe = re.compile( "\\x1b\\[(\\d+)A" ) 153downRe = re.compile( "\\x1b\\[(\\d+)B" ) 154 155def sym_to_raw( str_ ): 156 for sym, seq in keytab.items(): 157 if isinstance( str_, Rapid ): 158 str_ = Rapid( str_.replace( sym, seq ) ) 159 else: 160 str_ = str_.replace( sym, seq ) 161 return str_ 162 163def seq_to_sym( str_ ): 164 for seq, sym in termseq.items(): 165 str_ = str_.replace( seq, sym ) 166 str_ = colRe.sub( "<c\\1>", str_ ) 167 str_ = upRe.sub( "<u\\1>", str_ ) 168 str_ = downRe.sub( "<d\\1>", str_ ) 169 return str_ 170 171_words_ = [ 172 "ada", "algol" 173 "bash", "basic", 174 "clojure", "cobol", "csharp", 175 "eiffel", "erlang", 176 "forth", "fortran", "fsharp", 177 "go", "groovy", 178 "haskell", "huginn", 179 "java", "javascript", "julia", 180 "kotlin", 181 "lisp", "lua", 182 "modula", 183 "nemerle", 184 "ocaml", 185 "perl", "php", "prolog", "python", 186 "rebol", "ruby", "rust", 187 "scala", "scheme", "sql", "swift", 188 "typescript" 189] 190 191def skip( test_ ): 192 return "SKIP" in os.environ and os.environ["SKIP"].find( test_ ) >= 0 193 194verbosity = None 195 196class Rapid( str ): pass 197 198def rapid( item ): 199 if isinstance( item, str ): 200 r = Rapid( item ) 201 return r 202 return list( map( Rapid, item ) ) 203 204class ReplxxTests( unittest.TestCase ): 205 _prompt_ = "\033\\[1;32mreplxx\033\\[0m> " 206 _cxxSample_ = "./build/debug/replxx-example-cxx-api" 207 _cSample_ = "./build/debug/replxx-example-c-api" 208 _end_ = "\r\nExiting Replxx\r\n" 209 def send_str( self_, str_, intraKeyDelay_ ): 210 if isinstance(str_, Rapid): 211 self_._replxx.send( str_ ) 212 return 213 for char in str_: 214 self_._replxx.send( char ) 215 time.sleep( intraKeyDelay_ ) 216 217 def check_scenario( 218 self_, seq_, expected_, 219 history = "one\ntwo\nthree\n", 220 term = "xterm", 221 command = _cxxSample_, 222 dimensions = ( 25, 80 ), 223 prompt = _prompt_, 224 end = _prompt_ + _end_, 225 encoding = "utf-8", 226 pause = 0.25, 227 intraKeyDelay = 0.002 228 ): 229 with open( "replxx_history.txt", "wb" ) as f: 230 f.write( history.encode( encoding ) ) 231 f.close() 232 os.environ["TERM"] = term 233 if isinstance( command, str ): 234 command = command.replace( "\n", "~" ) 235 if verbosity >= 2: 236 print( "\nTERM: {}, SIZE: {}, CMD: {}".format( term, dimensions, command ) ) 237 prompt = prompt.replace( "\n", "\r\n" ).replace( "\r\r", "\r" ) 238 end = end.replace( "\n", "\r\n" ).replace( "\r\r", "\r" ) 239 if isinstance( command, str ): 240 self_._replxx = pexpect.spawn( command, maxread = 1, encoding = encoding, dimensions = dimensions ) 241 else: 242 self_._replxx = pexpect.spawn( command[0], args = command[1:], maxread = 1, encoding = encoding, dimensions = dimensions ) 243 self_._replxx.expect( prompt ) 244 self_.maxDiff = None 245 if isinstance( seq_, str ): 246 if isinstance( seq_, Rapid ): 247 seqs = rapid( seq_.split( "<c-z>" ) ) 248 else: 249 seqs = seq_.split( "<c-z>" ) 250 for seq in seqs: 251 last = seq is seqs[-1] 252 if not last: 253 seq += "<c-z>" 254 self_.send_str( sym_to_raw( seq ), intraKeyDelay ) 255 if not last: 256 time.sleep( pause ) 257 self_._replxx.kill( signal.SIGCONT ) 258 else: 259 for seq in seq_: 260 last = seq is seq_[-1] 261 self_.send_str( sym_to_raw( seq ), intraKeyDelay ) 262 if not last: 263 time.sleep( pause ) 264 self_._replxx.expect( end ) 265 if isinstance( expected_, str ): 266 self_.assertSequenceEqual( seq_to_sym( self_._replxx.before ), expected_ ) 267 else: 268 try: 269 self_.assertIn( seq_to_sym( self_._replxx.before ), expected_ ) 270 except: 271 self_.assertSequenceEqual( seq_to_sym( self_._replxx.before ), "" ) 272 def test_unicode( self_ ): 273 self_.check_scenario( 274 "<up><cr><c-d>", 275 "<c9>aóą Ϩ <rst><ceos><c21>" 276 "<c9>aóą Ϩ <rst><ceos><c21>\r\n" 277 "aóą Ϩ \r\n", 278 "aóą Ϩ \n" 279 ) 280 self_.check_scenario( 281 "aóą Ϩ <cr><c-d>", 282 "<c9>a<rst><ceos><c10><c9>aó<rst><ceos><c11><c9>aóą<rst><ceos><c12><c9>aóą " 283 "<rst><ceos><c13><c9>aóą Ϩ<rst><ceos><c14><c9>aóą Ϩ " 284 "<rst><ceos><c15><c9>aóą Ϩ <rst><ceos><c16><c9>aóą Ϩ " 285 "<rst><ceos><c17><c9>aóą Ϩ " 286 "<rst><ceos><c18><c9>aóą Ϩ <rst><ceos><c19><c9>aóą Ϩ " 287 "<rst><ceos><c20><c9>aóą Ϩ " 288 "<rst><ceos><c21><c9>aóą Ϩ <rst><ceos><c21>\r\n" 289 "aóą Ϩ \r\n" 290 ) 291 @unittest.skipIf( skip( "8bit_encoding" ), "broken platform" ) 292 def test_8bit_encoding( self_ ): 293 LC_CTYPE = "LC_CTYPE" 294 exists = LC_CTYPE in os.environ 295 lcCtype = None 296 if exists: 297 lcCtype = os.environ[LC_CTYPE] 298 os.environ[LC_CTYPE] = "pl_PL.ISO-8859-2" 299 self_.check_scenario( 300 "<aup><cr><c-d>", 301 "<c9>text ~ó~<rst><ceos><c17><c9>text ~ó~<rst><ceos><c17>\r\ntext ~ó~\r\n", 302 "text ~ó~\n", 303 encoding = "iso-8859-2" 304 ) 305 if exists: 306 os.environ[LC_CTYPE] = lcCtype 307 else: 308 del os.environ[LC_CTYPE] 309 def test_bad_term( self_ ): 310 self_.check_scenario( 311 "a line of text<cr><c-d>", 312 "a line of text\r\na line of text\r\n", 313 term = "dumb" 314 ) 315 def test_ctrl_c( self_ ): 316 self_.check_scenario( 317 "abc<c-c><c-d>", 318 "<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc<rst><ceos><c12>^C\r" 319 "\r\n" 320 ) 321 def test_ctrl_z( self_ ): 322 self_.check_scenario( 323 "<up><c-z><cr><c-d>", 324 "<c9>three<rst><ceos><c14><brightgreen>replxx<rst>> " 325 "<c9>three<rst><ceos><c14><c9>three<rst><ceos><c14>\r\n" 326 "three\r\n" 327 ) 328 self_.check_scenario( 329 "<c-r>w<c-z><cr><c-d>", 330 "<c1><ceos><c1><ceos>(reverse-i-search)`': " 331 "<c23><c1><ceos>(reverse-i-search)`w': " 332 "two<c25><c1><ceos>(reverse-i-search)`w': " 333 "two<c25><c1><ceos><brightgreen>replxx<rst>> " 334 "two<c10><c9><ceos><c12>\r\n" 335 "two\r\n" 336 ) 337 def test_ctrl_l( self_ ): 338 self_.check_scenario( 339 "<cr><cr><cr><c-l><c-d>", 340 "<c9><ceos><c9>\r\n" 341 "<brightgreen>replxx<rst>> <c9><ceos><c9>\r\n" 342 "<brightgreen>replxx<rst>> <c9><ceos><c9>\r\n" 343 "<brightgreen>replxx<rst>> <RIS><mvhm><clr><rst><brightgreen>replxx<rst>> " 344 "<c9><rst><ceos><c9>", 345 end = "\r\nExiting Replxx\r\n" 346 ) 347 self_.check_scenario( 348 "<cr><up><c-left><c-l><cr><c-d>", 349 "<c9><ceos><c9>\r\n" 350 "<brightgreen>replxx<rst>> <c9>first " 351 "second<rst><ceos><c21><c9>first " 352 "second<rst><ceos><c15><RIS><mvhm><clr><rst><brightgreen>replxx<rst>> " 353 "<c9>first second<rst><ceos><c15><c9>first second<rst><ceos><c21>\r\n" 354 "first second\r\n", 355 "first second\n" 356 ) 357 def test_backspace( self_ ): 358 self_.check_scenario( 359 "<up><c-a><m-f><c-right><backspace><backspace><backspace><backspace><cr><c-d>", 360 "<c9>one two three<rst><ceos><c22><c9>one two " 361 "three<rst><ceos><c9><c9>one two three<rst><ceos><c12><c9>one two " 362 "three<rst><ceos><c16><c9>one tw three<rst><ceos><c15><c9>one t " 363 "three<rst><ceos><c14><c9>one three<rst><ceos><c13><c9>one " 364 "three<rst><ceos><c12><c9>one three<rst><ceos><c18>\r\n" 365 "one three\r\n", 366 "one two three\n" 367 ) 368 def test_delete( self_ ): 369 self_.check_scenario( 370 "<up><m-b><c-left><del><c-d><del><c-d><cr><c-d>", 371 "<c9>one two three<rst><ceos><c22><c9>one two " 372 "three<rst><ceos><c17><c9>one two three<rst><ceos><c13><c9>one wo " 373 "three<rst><ceos><c13><c9>one o three<rst><ceos><c13><c9>one " 374 "three<rst><ceos><c13><c9>one three<rst><ceos><c13><c9>one three<rst><ceos><c18>\r\n" 375 "one three\r\n", 376 "one two three\n" 377 ) 378 def test_home_key( self_ ): 379 self_.check_scenario( 380 "abc<home>z<cr><c-d>", 381 "<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc<rst><ceos><c9><c9>zabc<rst><ceos><c10><c9>zabc<rst><ceos><c13>\r\n" 382 "zabc\r\n" 383 ) 384 def test_end_key( self_ ): 385 self_.check_scenario( 386 "abc<home>z<end>q<cr><c-d>", 387 "<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc<rst><ceos><c9><c9>zabc<rst><ceos><c10><c9>zabc<rst><ceos><c13><c9>zabcq<rst><ceos><c14><c9>zabcq<rst><ceos><c14>\r\n" 388 "zabcq\r\n" 389 ) 390 def test_left_key( self_ ): 391 self_.check_scenario( 392 "abc<left>x<aleft><left>y<cr><c-d>", 393 "<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc<rst><ceos><c11><c9>abxc<rst><ceos><c12><c9>abxc<rst><ceos><c11><c9>abxc<rst><ceos><c10><c9>aybxc<rst><ceos><c11><c9>aybxc<rst><ceos><c14>\r\n" 394 "aybxc\r\n" 395 ) 396 def test_right_key( self_ ): 397 self_.check_scenario( 398 "abc<home><right>x<aright>y<cr><c-d>", 399 "<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc<rst><ceos><c9><c9>abc<rst><ceos><c10><c9>axbc<rst><ceos><c11><c9>axbc<rst><ceos><c12><c9>axbyc<rst><ceos><c13><c9>axbyc<rst><ceos><c14>\r\n" 400 "axbyc\r\n" 401 ) 402 def test_prev_word_key( self_ ): 403 self_.check_scenario( 404 "abc def ghi<c-left><m-left>x<cr><c-d>", 405 "<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc " 406 "<rst><ceos><c13><c9>abc d<rst><ceos><c14><c9>abc " 407 "de<rst><ceos><c15><c9>abc def<rst><ceos><c16><c9>abc " 408 "def <rst><ceos><c17><c9>abc def " 409 "g<rst><ceos><c18><c9>abc def gh<rst><ceos><c19><c9>abc " 410 "def ghi<rst><ceos><c20><c9>abc def ghi<rst><ceos><c17><c9>abc def " 411 "ghi<rst><ceos><c13><c9>abc xdef ghi<rst><ceos><c14><c9>abc xdef " 412 "ghi<rst><ceos><c21>\r\n" 413 "abc xdef ghi\r\n" 414 ) 415 def test_next_word_key( self_ ): 416 self_.check_scenario( 417 "abc def ghi<home><c-right><m-right>x<cr><c-d>", 418 "<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abc " 419 "<rst><ceos><c13><c9>abc d<rst><ceos><c14><c9>abc " 420 "de<rst><ceos><c15><c9>abc def<rst><ceos><c16><c9>abc " 421 "def <rst><ceos><c17><c9>abc def " 422 "g<rst><ceos><c18><c9>abc def gh<rst><ceos><c19><c9>abc " 423 "def ghi<rst><ceos><c20><c9>abc def ghi<rst><ceos><c9><c9>abc def " 424 "ghi<rst><ceos><c12><c9>abc def ghi<rst><ceos><c16><c9>abc defx " 425 "ghi<rst><ceos><c17><c9>abc defx ghi<rst><ceos><c21>\r\n" 426 "abc defx ghi\r\n" 427 ) 428 def test_hint_show( self_ ): 429 self_.check_scenario( 430 "co\r<c-d>", 431 "<c9>c<rst><ceos><c10><c9>co<rst><ceos>\r\n" 432 " <gray>color_black<rst>\r\n" 433 " <gray>color_red<rst>\r\n" 434 " <gray>color_green<rst><u3><c11><c9>co<rst><ceos><c11>\r\n" 435 "co\r\n" 436 ) 437 self_.check_scenario( 438 "<up><cr><c-d>", 439 "<c9>zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz " 440 "<brightgreen>color_brightgreen<rst><ceos><c15><u3><c9>zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz " 441 "<brightgreen>color_brightgreen<rst><ceos><c15>\r\n" 442 "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz color_brightgreen\r\n", 443 "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz color_brightgreen\n", 444 dimensions = ( 64, 16 ) 445 ) 446 def test_hint_scroll_down( self_ ): 447 self_.check_scenario( 448 "co<c-down><c-down><tab><cr><c-d>", 449 "<c9>c<rst><ceos><c10><c9>co<rst><ceos>\r\n" 450 " <gray>color_black<rst>\r\n" 451 " <gray>color_red<rst>\r\n" 452 " " 453 "<gray>color_green<rst><u3><c11><c9>co<rst><ceos><gray>lor_black<rst>\r\n" 454 " <gray>color_red<rst>\r\n" 455 " <gray>color_green<rst>\r\n" 456 " " 457 "<gray>color_brown<rst><u3><c11><c9>co<rst><ceos><gray>lor_red<rst>\r\n" 458 " <gray>color_green<rst>\r\n" 459 " <gray>color_brown<rst>\r\n" 460 " " 461 "<gray>color_blue<rst><u3><c11><c9><red>color_red<rst><ceos><c18><c9><red>color_red<rst><ceos><c18>\r\n" 462 "color_red\r\n" 463 ) 464 def test_hint_scroll_up( self_ ): 465 self_.check_scenario( 466 "co<c-up><c-up><tab><cr><c-d>", 467 "<c9>c<rst><ceos><c10><c9>co<rst><ceos>\r\n" 468 " <gray>color_black<rst>\r\n" 469 " <gray>color_red<rst>\r\n" 470 " " 471 "<gray>color_green<rst><u3><c11><c9>co<rst><ceos><gray>lor_normal<rst>\r\n" 472 " <gray>co\r\n" 473 " <gray>color_black<rst>\r\n" 474 " " 475 "<gray>color_red<rst><u3><c11><c9>co<rst><ceos><gray>lor_white<rst>\r\n" 476 " <gray>color_normal<rst>\r\n" 477 " <gray>co\r\n" 478 " " 479 "<gray>color_black<rst><u3><c11><c9><white>color_white<rst><ceos><c20><c9><white>color_white<rst><ceos><c20>\r\n" 480 "color_white\r\n" 481 ) 482 def test_history( self_ ): 483 self_.check_scenario( 484 "<up><up><up><up><down><down><down><down>four<cr><c-d>", 485 "<c9>three<rst><ceos><c14><c9>two<rst><ceos><c12><c9>one<rst><ceos><c12><c9>two<rst><ceos><c12><c9>three<rst><ceos><c14><c9><rst><ceos><c9><c9>f<rst><ceos><c10><c9>fo<rst><ceos><c11><c9>fou<rst><ceos><c12><c9>four<rst><ceos><c13><c9>four<rst><ceos><c13>\r\n" 486 "four\r\n" 487 ) 488 with open( "replxx_history.txt", "rb" ) as f: 489 data = f.read().decode() 490 self_.assertSequenceEqual( data[:-33], "### 0000-00-00 00:00:00.000\none\n### 0000-00-00 00:00:00.000\ntwo\n### 0000-00-00 00:00:00.000\nthree\n" ) 491 self_.assertSequenceEqual( data[-5:], "four\n" ) 492 def test_paren_matching( self_ ): 493 self_.check_scenario( 494 "ab(cd)ef<left><left><left><left><left><left><left><cr><c-d>", 495 "<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c9>ab<brightmagenta>(<rst><ceos><c12><c9>ab<brightmagenta>(<rst>c<rst><ceos><c13><c9>ab<brightmagenta>(<rst>cd<rst><ceos><c14><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst><ceos><c15><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>e<rst><ceos><c16><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c17><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c16><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c15><c9>ab<brightred>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c14><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c13><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c12><c9>ab<brightmagenta>(<rst>cd<brightred>)<rst>ef<rst><ceos><c11><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c10><c9>ab<brightmagenta>(<rst>cd<brightmagenta>)<rst>ef<rst><ceos><c17>\r\n" 496 "ab(cd)ef\r\n" 497 ) 498 def test_paren_not_matched( self_ ): 499 self_.check_scenario( 500 "a(b[c)d<left><left><left><left><left><left><left><cr><c-d>", 501 "<c9>a<rst><ceos><c10><c9>a<brightmagenta>(<rst><ceos><c11><c9>a<brightmagenta>(<rst>b<rst><ceos><c12><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst><ceos><c13><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<rst><ceos><c14><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst><ceos><c15><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c16><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c15><c9>a<err>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c14><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c13><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c12><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c11><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<err>)<rst>d<rst><ceos><c10><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c9><c9>a<brightmagenta>(<rst>b<brightmagenta>[<rst>c<brightmagenta>)<rst>d<rst><ceos><c16>\r\n" 502 "a(b[c)d\r\n" 503 ) 504 def test_tab_completion( self_ ): 505 self_.check_scenario( 506 "co<tab><tab>bri<tab>b<tab><cr><c-d>", 507 "<c9>c<rst><ceos><c10><c9>co<rst><ceos>\r\n" 508 " <gray>color_black<rst>\r\n" 509 " <gray>color_red<rst>\r\n" 510 " <gray>color_green<rst><u3><c11><c9>color_<rst><ceos>\r\n" 511 " <gray>color_black<rst>\r\n" 512 " <gray>color_red<rst>\r\n" 513 " <gray>color_green<rst><u3><c15><c9>color_<rst><ceos><c15>\r\n" 514 "<brightmagenta>color_<rst>black " 515 "<brightmagenta>color_<rst>cyan " 516 "<brightmagenta>color_<rst>brightblue\r\n" 517 "<brightmagenta>color_<rst><red>red<rst> " 518 "<brightmagenta>color_<rst>lightgray " 519 "<brightmagenta>color_<rst>brightmagenta\r\n" 520 "<brightmagenta>color_<rst>green " 521 "<brightmagenta>color_<rst>gray " 522 "<brightmagenta>color_<rst>brightcyan\r\n" 523 "<brightmagenta>color_<rst>brown " 524 "<brightmagenta>color_<rst><brightred>brightred<rst> <brightmagenta>color_<rst>white\r\n" 525 "<brightmagenta>color_<rst>blue " 526 "<brightmagenta>color_<rst>brightgreen <brightmagenta>color_<rst>normal\r\n" 527 "<brightmagenta>color_<rst>magenta <brightmagenta>color_<rst>yellow\r\n" 528 "<brightgreen>replxx<rst>> <c9>color_<rst><ceos>\r\n" 529 " <gray>color_black<rst>\r\n" 530 " <gray>color_red<rst>\r\n" 531 " <gray>color_green<rst><u3><c15><c9>color_b<rst><ceos>\r\n" 532 " <gray>color_black<rst>\r\n" 533 " <gray>color_brown<rst>\r\n" 534 " <gray>color_blue<rst><u3><c16><c9>color_br<rst><ceos>\r\n" 535 " <gray>color_brown<rst>\r\n" 536 " <gray>color_brightred<rst>\r\n" 537 " " 538 "<gray>color_brightgreen<rst><u3><c17><c9>color_bri<rst><ceos>\r\n" 539 " <gray>color_brightred<rst>\r\n" 540 " <gray>color_brightgreen<rst>\r\n" 541 " " 542 "<gray>color_brightblue<rst><u3><c18><c9>color_bright<rst><ceos>\r\n" 543 " <gray>color_brightred<rst>\r\n" 544 " <gray>color_brightgreen<rst>\r\n" 545 " " 546 "<gray>color_brightblue<rst><u3><c21><c9>color_brightb<rst><ceos><green>lue<rst><c22><c9><brightblue>color_brightblue<rst><ceos><c25><c9><brightblue>color_brightblue<rst><ceos><c25>\r\n" 547 "color_brightblue\r\n" 548 ) 549 self_.check_scenario( 550 "<tab><tab>n<cr><c-d>", 551 "<bell><bell><c9>n<rst><ceos><c10><c9>n<rst><ceos><c10>\r\nn\r\n", 552 dimensions = ( 4, 32 ), 553 command = [ ReplxxTests._cSample_, "q1", "e0" ] 554 ) 555 self_.check_scenario( 556 "<tab><tab>n<cr><c-d>", 557 "<c9><ceos><c9>\r\n" 558 "db\r\n" 559 "hello\r\n" 560 "hallo\r\n" 561 "--More--<bell>\r" 562 "\t\t\t\t\r" 563 "<brightgreen>replxx<rst>> " 564 "<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n", 565 dimensions = ( 4, 24 ), 566 command = ReplxxTests._cSample_ + " q1 e1" 567 ) 568 self_.check_scenario( 569 "<up><home>co<tab><cr><c-d>", 570 "<c9>abcd<brightmagenta>()<rst><ceos><c15>" 571 "<c9>abcd<brightmagenta>()<rst><ceos><c9>" 572 "<c9>cabcd<brightmagenta>()<rst><ceos><c10>" 573 "<c9>coabcd<brightmagenta>()<rst><ceos><c11>" 574 "<c9>color_abcd<brightmagenta>()<rst><ceos><c15>" 575 "<c9>color_abcd<brightmagenta>()<rst><ceos><c21>\r\n" 576 "color_abcd()\r\n", 577 "abcd()\n" 578 ) 579 def test_completion_shorter_result( self_ ): 580 self_.check_scenario( 581 "<up><tab><cr><c-d>", 582 "<c9>\\pi<rst><ceos><c12><c9>π<rst><ceos><c10><c9>π<rst><ceos><c10>\r\n" 583 "π\r\n", 584 "\\pi\n" 585 ) 586 def test_completion_pager( self_ ): 587 cmd = ReplxxTests._cSample_ + " q1 x" + ",".join( _words_ ) 588 self_.check_scenario( 589 "<tab>py<cr><c-d>", 590 "<c9><ceos><c9>\r\n" 591 "ada groovy perl\r\n" 592 "algolbash haskell php\r\n" 593 "basic huginn prolog\r\n" 594 "clojure java python\r\n" 595 "cobol javascript rebol\r\n" 596 "csharp julia ruby\r\n" 597 "eiffel kotlin rust\r\n" 598 "erlang lisp scala\r\n" 599 "forth lua scheme\r\n" 600 "--More--<bell>\r" 601 "\t\t\t\t\r" 602 "fortran modula sql\r\n" 603 "fsharp nemerle swift\r\n" 604 "go ocaml typescript\r\n" 605 "<brightgreen>replxx<rst>> " 606 "<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n", 607 dimensions = ( 10, 40 ), 608 command = cmd 609 ) 610 self_.check_scenario( 611 "<tab><cr><cr><cr><cr><c-d>", 612 "<c9><ceos><c9>\r\n" 613 "ada groovy perl\r\n" 614 "algolbash haskell php\r\n" 615 "basic huginn prolog\r\n" 616 "clojure java python\r\n" 617 "cobol javascript rebol\r\n" 618 "csharp julia ruby\r\n" 619 "eiffel kotlin rust\r\n" 620 "erlang lisp scala\r\n" 621 "forth lua scheme\r\n" 622 "--More--\r" 623 "\t\t\t\t\r" 624 "fortran modula sql\r\n" 625 "--More--\r" 626 "\t\t\t\t\r" 627 "fsharp nemerle swift\r\n" 628 "--More--\r" 629 "\t\t\t\t\r" 630 "go ocaml typescript\r\n" 631 "<brightgreen>replxx<rst>> " 632 "<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n", 633 dimensions = ( 10, 40 ), 634 command = cmd 635 ) 636 self_.check_scenario( 637 "<tab><c-c><cr><c-d>", 638 "<c9><ceos><c9>\r\n" 639 "ada kotlin\r\n" 640 "algolbash lisp\r\n" 641 "basic lua\r\n" 642 "clojure modula\r\n" 643 "cobol nemerle\r\n" 644 "csharp ocaml\r\n" 645 "eiffel perl\r\n" 646 "--More--^C\r\n" 647 "<brightgreen>replxx<rst>> " 648 "<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n", 649 dimensions = ( 8, 32 ), 650 command = cmd 651 ) 652 self_.check_scenario( 653 "<tab>q<cr><c-d>", 654 "<c9><ceos><c9>\r\n" 655 "ada kotlin\r\n" 656 "algolbash lisp\r\n" 657 "basic lua\r\n" 658 "clojure modula\r\n" 659 "cobol nemerle\r\n" 660 "csharp ocaml\r\n" 661 "eiffel perl\r\n" 662 "--More--\r" 663 "\t\t\t\t\r" 664 "<brightgreen>replxx<rst>> " 665 "<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n", 666 dimensions = ( 8, 32 ), 667 command = cmd 668 ) 669 def test_double_tab_completion( self_ ): 670 cmd = ReplxxTests._cSample_ + " d1 q1 x" + ",".join( _words_ ) 671 self_.check_scenario( 672 "fo<tab><tab>r<tab><cr><c-d>", 673 "<c9>f<rst><ceos>\r\n" 674 " <gray>forth<rst>\r\n" 675 " <gray>fortran<rst>\r\n" 676 " <gray>fsharp<rst><u3><c10><c9>fo<rst><ceos>\r\n" 677 " <gray>forth<rst>\r\n" 678 " <gray>fortran<rst><u2><c11><c9>fort<rst><ceos>\r\n" 679 " <gray>forth<rst>\r\n" 680 " " 681 "<gray>fortran<rst><u2><c13><c9>fortr<rst><ceos><gray>an<rst><c14><c9>fortran<rst><ceos><c16><c9>fortran<rst><ceos><c16>\r\n" 682 "fortran\r\n", 683 command = cmd 684 ) 685 def test_beep_on_ambiguous_completion( self_ ): 686 cmd = ReplxxTests._cSample_ + " b1 d1 q1 x" + ",".join( _words_ ) 687 self_.check_scenario( 688 "fo<tab><tab>r<tab><cr><c-d>", 689 "<c9>f<rst><ceos>\r\n" 690 " <gray>forth<rst>\r\n" 691 " <gray>fortran<rst>\r\n" 692 " <gray>fsharp<rst><u3><c10><c9>fo<rst><ceos>\r\n" 693 " <gray>forth<rst>\r\n" 694 " <gray>fortran<rst><u2><c11><bell><c9>fort<rst><ceos>\r\n" 695 " <gray>forth<rst>\r\n" 696 " " 697 "<gray>fortran<rst><u2><c13><bell><c9>fortr<rst><ceos><gray>an<rst><c14><c9>fortran<rst><ceos><c16><c9>fortran<rst><ceos><c16>\r\n" 698 "fortran\r\n", 699 command = cmd 700 ) 701 def test_history_search_backward( self_ ): 702 self_.check_scenario( 703 "<c-r>repl<c-r><cr><c-d>", 704 "<c1><ceos><c1><ceos>(reverse-i-search)`': " 705 "<c23><c1><ceos>(reverse-i-search)`r': echo repl " 706 "golf<c29><c1><ceos>(reverse-i-search)`re': echo repl " 707 "golf<c30><c1><ceos>(reverse-i-search)`rep': echo repl " 708 "golf<c31><c1><ceos>(reverse-i-search)`repl': echo repl " 709 "golf<c32><c1><ceos>(reverse-i-search)`repl': charlie repl " 710 "delta<c35><c1><ceos><brightgreen>replxx<rst>> charlie repl " 711 "delta<c17><c9><ceos><c27>\r\n" 712 "charlie repl delta\r\n", 713 "some command\n" 714 "alfa repl bravo\n" 715 "other request\n" 716 "charlie repl delta\n" 717 "misc input\n" 718 "echo repl golf\n" 719 "final thoughts\n" 720 ) 721 self_.check_scenario( 722 "<c-r>for<backspace><backspace>s<cr><c-d>", 723 "<c1><ceos><c1><ceos>(reverse-i-search)`': " 724 "<c23><c1><ceos>(reverse-i-search)`f': " 725 "swift<c27><c1><ceos>(reverse-i-search)`fo': " 726 "fortran<c25><c1><ceos>(reverse-i-search)`for': " 727 "fortran<c26><c1><ceos>(reverse-i-search)`fo': " 728 "fortran<c25><c1><ceos>(reverse-i-search)`f': " 729 "swift<c27><c1><ceos>(reverse-i-search)`fs': " 730 "fsharp<c25><c1><ceos><brightgreen>replxx<rst>> " 731 "fsharp<c9><c9><ceos><c15>\r\n" 732 "fsharp\r\n", 733 "\n".join( _words_ ) + "\n" 734 ) 735 self_.check_scenario( 736 "<c-r>mod<c-l><cr><c-d>", 737 "<c1><ceos><c1><ceos>(reverse-i-search)`': " 738 "<c23><c1><ceos>(reverse-i-search)`m': " 739 "scheme<c28><c1><ceos>(reverse-i-search)`mo': " 740 "modula<c25><c1><ceos>(reverse-i-search)`mod': " 741 "modula<c26><c1><ceos><brightgreen>replxx<rst>> " 742 "<c9><RIS><mvhm><clr><rst><brightgreen>replxx<rst>> " 743 "<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n", 744 "\n".join( _words_ ) + "\n" 745 ) 746 def test_history_search_backward_position( self_ ): 747 self_.check_scenario( 748 "<c-r>req<up><cr><c-d>", 749 "<c1><ceos><c1><ceos>(reverse-i-search)`': " 750 "<c23><c1><ceos>(reverse-i-search)`r': echo repl " 751 "golf<c29><c1><ceos>(reverse-i-search)`re': echo repl " 752 "golf<c30><c1><ceos>(reverse-i-search)`req': other " 753 "request<c32><c1><ceos><brightgreen>replxx<rst>> other request<c15><c9>alfa " 754 "repl bravo<rst><ceos><c24><c9>alfa repl bravo<rst><ceos><c24>\r\n" 755 "alfa repl bravo\r\n", 756 "some command\n" 757 "alfa repl bravo\n" 758 "other request\n" 759 "charlie repl delta\n" 760 "misc input\n" 761 "echo repl golf\n" 762 "final thoughts\n" 763 ) 764 def test_history_search_overlong_line( self_ ): 765 self_.check_scenario( 766 "<c-r>lo<cr><c-d>", 767 "<c1><ceos><c1><ceos>(reverse-i-search)`': " 768 "<c23><c1><ceos>(reverse-i-search)`l': some very long line of text, much " 769 "longer then a witdth of a terminal, " 770 "seriously<c37><u1><c1><ceos>(reverse-i-search)`lo': some very long line of " 771 "text, much longer then a witdth of a terminal, " 772 "seriously<u1><c59><c1><ceos><brightgreen>replxx<rst>> some very long line of " 773 "text, much longer then a witdth of a terminal, " 774 "seriously<u1><c43><c9><ceos><c24>\r\n" 775 "some very long line of text, much longer then a witdth of a terminal, " 776 "seriously\r\n", 777 "fake\nsome very long line of text, much longer then a witdth of a terminal, seriously\nanother fake", 778 dimensions = ( 24, 64 ) 779 ) 780 def test_history_prefix_search_backward( self_ ): 781 self_.check_scenario( 782 "repl<m-p><m-p><cr><c-d>", 783 "<c9>r<rst><ceos><c10><c9>re<rst><ceos><c11><c9>rep<rst><ceos><c12><c9>repl<rst><ceos><c13><c9>repl_echo " 784 "golf<rst><ceos><c23><c9>repl_charlie " 785 "delta<rst><ceos><c27><c9>repl_charlie delta<rst><ceos><c27>\r\n" 786 "repl_charlie delta\r\n", 787 "some command\n" 788 "repl_alfa bravo\n" 789 "other request\n" 790 "repl_charlie delta\n" 791 "misc input\n" 792 "repl_echo golf\n" 793 "final thoughts\n" 794 ) 795 def test_history_prefix_search_backward_position( self_ ): 796 self_.check_scenario( 797 "repl<m-p><up><cr><c-d>", 798 "<c9>r<rst><ceos><c10><c9>re<rst><ceos><c11><c9>rep<rst><ceos><c12><c9>repl<rst><ceos><c13><c9>repl_echo " 799 "golf<rst><ceos><c23><c9>misc input<rst><ceos><c19><c9>misc " 800 "input<rst><ceos><c19>\r\n" 801 "misc input\r\n", 802 "some command\n" 803 "repl_alfa bravo\n" 804 "other request\n" 805 "repl_charlie delta\n" 806 "misc input\n" 807 "repl_echo golf\n" 808 "final thoughts\n" 809 ) 810 def test_history_listing( self_ ): 811 self_.check_scenario( 812 "<up><cr><c-d>", 813 "<c9><brightmagenta>.history<rst><ceos><c17><c9><brightmagenta>.history<rst><ceos><c17>\r\n" 814 " 0: some command\r\n" 815 " 1: repl_alfa bravo\r\n" 816 " 2: other request\r\n" 817 " 3: repl_charlie delta\r\n" 818 " 4: misc input\r\n" 819 " 5: repl_echo golf\r\n" 820 " 6: .history\r\n", 821 "some command\n" 822 "repl_alfa bravo\n" 823 "other request\n" 824 "repl_charlie delta\n" 825 "misc input\n" 826 "repl_echo golf\n" 827 ".history\n" 828 ) 829 self_.check_scenario( 830 "<up><cr><c-d>", 831 "<c9>/history<rst><ceos><c17><c9>/history<rst><ceos><c17>\r\n" 832 " 0: some command\r\n" 833 " 1: repl_alfa bravo\r\n" 834 " 2: other request\r\n" 835 " 3: repl_charlie delta\r\n" 836 " 4: misc input\r\n" 837 " 5: repl_echo golf\r\n" 838 " 6: /history\r\n" 839 "/history\r\n", 840 "some command\n" 841 "repl_alfa bravo\n" 842 "other request\n" 843 "repl_charlie delta\n" 844 "misc input\n" 845 "repl_echo golf\n" 846 "/history\n", 847 command = ReplxxTests._cSample_ + " q1" 848 ) 849 def test_history_browse( self_ ): 850 self_.check_scenario( 851 "<up><aup><pgup><down><up><up><adown><pgdown><up><down><down><up><cr><c-d>", 852 "<c9>twelve<rst><ceos><c15>" 853 "<c9>eleven<rst><ceos><c15>" 854 "<c9>one<rst><ceos><c12>" 855 "<c9>two<rst><ceos><c12>" 856 "<c9>one<rst><ceos><c12>" 857 "<c9>two<rst><ceos><c12>" 858 "<c9><rst><ceos><c9>" 859 "<c9>twelve<rst><ceos><c15>" 860 "<c9><rst><ceos><c9>" 861 "<c9>twelve<rst><ceos><c15>" 862 "<c9>twelve<rst><ceos><c15>\r\n" 863 "twelve\r\n", 864 "one\n" 865 "two\n" 866 "three\n" 867 "four\n" 868 "five\n" 869 "six\n" 870 "seven\n" 871 "eight\n" 872 "nine\n" 873 "ten\n" 874 "eleven\n" 875 "twelve\n" 876 ) 877 def test_history_max_size( self_ ): 878 self_.check_scenario( 879 "<pgup><pgdown>a<cr><pgup><cr><c-d>", 880 "<c9>three<rst><ceos><c14><c9><rst><ceos><c9><c9>a<rst><ceos><c10><c9>a<rst><ceos><c10>\r\n" 881 "a\r\n" 882 "<brightgreen>replxx<rst>> " 883 "<c9>four<rst><ceos><c13><c9>four<rst><ceos><c13>\r\n" 884 "four\r\n", 885 "one\n" 886 "two\n" 887 "three\n" 888 "four\n" 889 "five\n", 890 command = ReplxxTests._cSample_ + " q1 s3" 891 ) 892 def test_history_unique( self_ ): 893 self_.check_scenario( 894 "a<cr>b<cr>a<cr>b<cr><up><up><up><cr><c-d>", 895 "<c9>a<rst><ceos><c10><c9>a<rst><ceos><c10>\r\n" 896 "a\r\n" 897 "<brightgreen>replxx<rst>> <c9>b<rst><ceos><c10><c9>b<rst><ceos><c10>\r\n" 898 "b\r\n" 899 "<brightgreen>replxx<rst>> <c9>a<rst><ceos><c10><c9>a<rst><ceos><c10>\r\n" 900 "a\r\n" 901 "<brightgreen>replxx<rst>> <c9>b<rst><ceos><c10><c9>b<rst><ceos><c10>\r\n" 902 "b\r\n" 903 "<brightgreen>replxx<rst>> " 904 "<c9>b<rst><ceos><c10><c9>a<rst><ceos><c10><c9>c<rst><ceos><c10><c9>c<rst><ceos><c10>\r\n" 905 "c\r\n", 906 "a\nb\nc\n", 907 command = ReplxxTests._cSample_ + " u1 q1" 908 ) 909 self_.check_scenario( 910 "a<cr>b<cr>a<cr>b<cr><up><up><up><cr><c-d>", 911 "<c9>a<rst><ceos><c10><c9>a<rst><ceos><c10>\r\n" 912 "a\r\n" 913 "<brightgreen>replxx<rst>> <c9>b<rst><ceos><c10><c9>b<rst><ceos><c10>\r\n" 914 "b\r\n" 915 "<brightgreen>replxx<rst>> <c9>a<rst><ceos><c10><c9>a<rst><ceos><c10>\r\n" 916 "a\r\n" 917 "<brightgreen>replxx<rst>> <c9>b<rst><ceos><c10><c9>b<rst><ceos><c10>\r\n" 918 "b\r\n" 919 "<brightgreen>replxx<rst>> " 920 "<c9>b<rst><ceos><c10><c9>a<rst><ceos><c10><c9>b<rst><ceos><c10><c9>b<rst><ceos><c10>\r\n" 921 "b\r\n", 922 "a\nb\nc\n", 923 command = ReplxxTests._cSample_ + " u0 q1" 924 ) 925 self_.check_scenario( 926 rapid( "/history\n/unique\n/history\n<c-d>" ), 927 "<c9>/<rst><ceos><c10><c9>/history<rst><ceos><c17>\r\n" 928 " 0: a\r\n" 929 " 1: b\r\n" 930 " 2: c\r\n" 931 " 3: b\r\n" 932 " 4: c\r\n" 933 " 5: d\r\n" 934 " 6: a\r\n" 935 " 7: c\r\n" 936 " 8: c\r\n" 937 " 9: a\r\n" 938 "/history\r\n" 939 "<brightgreen>replxx<rst>> <c9>/unique<rst><ceos><c16>\r\n" 940 "/unique\r\n" 941 "<brightgreen>replxx<rst>> <c9>/history<rst><ceos><c17>\r\n" 942 " 0: b\r\n" 943 " 1: d\r\n" 944 " 2: c\r\n" 945 " 3: a\r\n" 946 " 4: /history\r\n" 947 " 5: /unique\r\n" 948 "/history\r\n", 949 "a\nb\nc\nb\nc\nd\na\nc\nc\na\n", 950 command = ReplxxTests._cSample_ + " u0 q1" 951 ) 952 def test_history_recall_most_recent( self_ ): 953 self_.check_scenario( 954 "<pgup><down><cr><down><cr><c-d>", 955 "<c9>aaaa<rst><ceos><c13><c9>bbbb<rst><ceos><c13><c9>bbbb<rst><ceos><c13>\r\n" 956 "bbbb\r\n" 957 "<brightgreen>replxx<rst>> " 958 "<c9>cccc<rst><ceos><c13><c9>cccc<rst><ceos><c13>\r\n" 959 "cccc\r\n", 960 "aaaa\nbbbb\ncccc\ndddd\n" 961 ) 962 def test_history_abort_incremental_history_search_position( self_ ): 963 self_.check_scenario( 964 "<up><up><c-r>cc<c-c><up><cr><c-d>", 965 "<c9>hhhh<rst><ceos><c13><c9>gggg<rst><ceos><c13><c1><ceos><c1><ceos>(reverse-i-search)`': " 966 "gggg<c27><c1><ceos>(reverse-i-search)`c': " 967 "cccc<c27><c1><ceos>(reverse-i-search)`cc': " 968 "cccc<c27><c1><ceos><brightgreen>replxx<rst>> " 969 "gggg<c13><c9>gggg<rst><ceos><c13><c9>ffff<rst><ceos><c13><c9>ffff<rst><ceos><c13>\r\n" 970 "ffff\r\n", 971 "aaaa\nbbbb\ncccc\ndddd\neeee\nffff\ngggg\nhhhh\n" 972 ) 973 def test_capitalize( self_ ): 974 self_.check_scenario( 975 "<up><home><right><m-c><m-c><right><right><m-c><m-c><m-c><cr><c-d>", 976 "<c9>abc defg ijklmn zzxq<rst><ceos><c29><c9>abc defg ijklmn " 977 "zzxq<rst><ceos><c9><c9>abc defg ijklmn zzxq<rst><ceos><c10><c9>aBc defg " 978 "ijklmn zzxq<rst><ceos><c12><c9>aBc Defg ijklmn zzxq<rst><ceos><c17><c9>aBc " 979 "Defg ijklmn zzxq<rst><ceos><c18><c9>aBc Defg ijklmn " 980 "zzxq<rst><ceos><c19><c9>aBc Defg iJklmn zzxq<rst><ceos><c24><c9>aBc Defg " 981 "iJklmn Zzxq<rst><ceos><c29><c9>aBc Defg iJklmn Zzxq<rst><ceos><c29>\r\n" 982 "aBc Defg iJklmn Zzxq\r\n", 983 "abc defg ijklmn zzxq\n" 984 ) 985 def test_make_upper_case( self_ ): 986 self_.check_scenario( 987 "<up><home><right><right><right><m-u><m-u><right><m-u><cr><c-d>", 988 "<c9>abcdefg hijklmno pqrstuvw<rst><ceos><c34><c9>abcdefg " 989 "hijklmno pqrstuvw<rst><ceos><c9><c9>abcdefg hijklmno " 990 "pqrstuvw<rst><ceos><c10><c9>abcdefg hijklmno " 991 "pqrstuvw<rst><ceos><c11><c9>abcdefg hijklmno " 992 "pqrstuvw<rst><ceos><c12><c9>abcDEFG hijklmno " 993 "pqrstuvw<rst><ceos><c16><c9>abcDEFG HIJKLMNO " 994 "pqrstuvw<rst><ceos><c25><c9>abcDEFG HIJKLMNO " 995 "pqrstuvw<rst><ceos><c26><c9>abcDEFG HIJKLMNO " 996 "PQRSTUVW<rst><ceos><c34><c9>abcDEFG HIJKLMNO " 997 "PQRSTUVW<rst><ceos><c34>\r\n" 998 "abcDEFG HIJKLMNO PQRSTUVW\r\n", 999 "abcdefg hijklmno pqrstuvw\n" 1000 ) 1001 def test_make_lower_case( self_ ): 1002 self_.check_scenario( 1003 "<up><home><right><right><right><m-l><m-l><right><m-l><cr><c-d>", 1004 "<c9>ABCDEFG HIJKLMNO PQRSTUVW<rst><ceos><c34><c9>ABCDEFG " 1005 "HIJKLMNO PQRSTUVW<rst><ceos><c9><c9>ABCDEFG HIJKLMNO " 1006 "PQRSTUVW<rst><ceos><c10><c9>ABCDEFG HIJKLMNO " 1007 "PQRSTUVW<rst><ceos><c11><c9>ABCDEFG HIJKLMNO " 1008 "PQRSTUVW<rst><ceos><c12><c9>ABCdefg HIJKLMNO " 1009 "PQRSTUVW<rst><ceos><c16><c9>ABCdefg hijklmno " 1010 "PQRSTUVW<rst><ceos><c25><c9>ABCdefg hijklmno " 1011 "PQRSTUVW<rst><ceos><c26><c9>ABCdefg hijklmno " 1012 "pqrstuvw<rst><ceos><c34><c9>ABCdefg hijklmno " 1013 "pqrstuvw<rst><ceos><c34>\r\n" 1014 "ABCdefg hijklmno pqrstuvw\r\n", 1015 "ABCDEFG HIJKLMNO PQRSTUVW\n" 1016 ) 1017 def test_transpose( self_ ): 1018 self_.check_scenario( 1019 "<up><home><c-t><right><c-t><c-t><c-t><c-t><c-t><cr><c-d>", 1020 "<c9>abcd<rst><ceos><c13>" 1021 "<c9>abcd<rst><ceos><c9>" 1022 "<c9>abcd<rst><ceos><c10>" 1023 "<c9>bacd<rst><ceos><c11>" 1024 "<c9>bcad<rst><ceos><c12>" 1025 "<c9>bcda<rst><ceos><c13>" 1026 "<c9>bcad<rst><ceos><c13>" 1027 "<c9>bcda<rst><ceos><c13>" 1028 "<c9>bcda<rst><ceos><c13>\r\n" 1029 "bcda\r\n", 1030 "abcd\n" 1031 ) 1032 def test_kill_to_beginning_of_line( self_ ): 1033 self_.check_scenario( 1034 "<up><home><c-right><c-right><right><c-u><end><c-y><cr><c-d>", 1035 "<c9><brightblue>+<rst>abc defg<brightblue>--<rst>ijklmn " 1036 "zzxq<brightblue>+<rst><ceos><c32><c9><brightblue>+<rst>abc " 1037 "defg<brightblue>--<rst>ijklmn " 1038 "zzxq<brightblue>+<rst><ceos><c9><c9><brightblue>+<rst>abc " 1039 "defg<brightblue>--<rst>ijklmn " 1040 "zzxq<brightblue>+<rst><ceos><c13><c9><brightblue>+<rst>abc " 1041 "defg<brightblue>--<rst>ijklmn " 1042 "zzxq<brightblue>+<rst><ceos><c18><c9><brightblue>+<rst>abc " 1043 "defg<brightblue>--<rst>ijklmn " 1044 "zzxq<brightblue>+<rst><ceos><c19><c9><brightblue>-<rst>ijklmn " 1045 "zzxq<brightblue>+<rst><ceos><c9><c9><brightblue>-<rst>ijklmn " 1046 "zzxq<brightblue>+<rst><ceos><c22><c9><brightblue>-<rst>ijklmn " 1047 "zzxq<brightblue>++<rst>abc " 1048 "defg<brightblue>-<rst><ceos><c32><c9><brightblue>-<rst>ijklmn " 1049 "zzxq<brightblue>++<rst>abc defg<brightblue>-<rst><ceos><c32>\r\n" 1050 "-ijklmn zzxq++abc defg-\r\n", 1051 "+abc defg--ijklmn zzxq+\n" 1052 ) 1053 def test_kill_to_end_of_line( self_ ): 1054 self_.check_scenario( 1055 "<up><home><c-right><c-right><right><c-k><home><c-y><cr><c-d>", 1056 "<c9><brightblue>+<rst>abc defg<brightblue>--<rst>ijklmn " 1057 "zzxq<brightblue>+<rst><ceos><c32><c9><brightblue>+<rst>abc " 1058 "defg<brightblue>--<rst>ijklmn " 1059 "zzxq<brightblue>+<rst><ceos><c9><c9><brightblue>+<rst>abc " 1060 "defg<brightblue>--<rst>ijklmn " 1061 "zzxq<brightblue>+<rst><ceos><c13><c9><brightblue>+<rst>abc " 1062 "defg<brightblue>--<rst>ijklmn " 1063 "zzxq<brightblue>+<rst><ceos><c18><c9><brightblue>+<rst>abc " 1064 "defg<brightblue>--<rst>ijklmn " 1065 "zzxq<brightblue>+<rst><ceos><c19><c9><brightblue>+<rst>abc " 1066 "defg<brightblue>-<rst><ceos><c19><c9><brightblue>+<rst>abc " 1067 "defg<brightblue>-<rst><ceos><c9><c9><brightblue>-<rst>ijklmn " 1068 "zzxq<brightblue>++<rst>abc " 1069 "defg<brightblue>-<rst><ceos><c22><c9><brightblue>-<rst>ijklmn " 1070 "zzxq<brightblue>++<rst>abc defg<brightblue>-<rst><ceos><c32>\r\n" 1071 "-ijklmn zzxq++abc defg-\r\n", 1072 "+abc defg--ijklmn zzxq+\n" 1073 ) 1074 def test_kill_next_word( self_ ): 1075 self_.check_scenario( 1076 "<up><home><c-right><m-d><c-right><c-y><cr><c-d>", 1077 "<c9>alpha charlie bravo delta<rst><ceos><c34><c9>alpha " 1078 "charlie bravo delta<rst><ceos><c9><c9>alpha charlie bravo " 1079 "delta<rst><ceos><c14><c9>alpha bravo delta<rst><ceos><c14><c9>alpha bravo " 1080 "delta<rst><ceos><c20><c9>alpha bravo charlie delta<rst><ceos><c28><c9>alpha " 1081 "bravo charlie delta<rst><ceos><c34>\r\n" 1082 "alpha bravo charlie delta\r\n", 1083 "alpha charlie bravo delta\n" 1084 ) 1085 def test_kill_prev_word_to_white_space( self_ ): 1086 self_.check_scenario( 1087 "<up><c-left><c-w><c-left><c-y><cr><c-d>", 1088 "<c9>alpha charlie bravo delta<rst><ceos><c34><c9>alpha " 1089 "charlie bravo delta<rst><ceos><c29><c9>alpha charlie " 1090 "delta<rst><ceos><c23><c9>alpha charlie delta<rst><ceos><c15><c9>alpha bravo " 1091 "charlie delta<rst><ceos><c21><c9>alpha bravo charlie delta<rst><ceos><c34>\r\n" 1092 "alpha bravo charlie delta\r\n", 1093 "alpha charlie bravo delta\n" 1094 ) 1095 def test_kill_prev_word( self_ ): 1096 self_.check_scenario( 1097 "<up><c-left><m-backspace><c-left><c-y><cr><c-d>", 1098 "<c9>alpha<brightmagenta>.<rst>charlie " 1099 "bravo<brightmagenta>.<rst>delta<rst><ceos><c34><c9>alpha<brightmagenta>.<rst>charlie " 1100 "bravo<brightmagenta>.<rst>delta<rst><ceos><c29><c9>alpha<brightmagenta>.<rst>charlie " 1101 "delta<rst><ceos><c23><c9>alpha<brightmagenta>.<rst>charlie " 1102 "delta<rst><ceos><c15><c9>alpha<brightmagenta>.<rst>bravo<brightmagenta>.<rst>charlie " 1103 "delta<rst><ceos><c21><c9>alpha<brightmagenta>.<rst>bravo<brightmagenta>.<rst>charlie " 1104 "delta<rst><ceos><c34>\r\n" 1105 "alpha.bravo.charlie delta\r\n", 1106 "alpha.charlie bravo.delta\n" 1107 ) 1108 def test_kill_ring( self_ ): 1109 self_.check_scenario( 1110 "<up><c-w><backspace><c-w><backspace><c-w><backspace><c-u><c-y><m-y><m-y><m-y> <c-y><m-y><m-y><m-y> <c-y><m-y><m-y><m-y> <c-y><m-y><m-y><m-y><cr><c-d>", 1111 "<c9>delta charlie bravo alpha<rst><ceos><c34><c9>delta " 1112 "charlie bravo <rst><ceos><c29><c9>delta charlie " 1113 "bravo<rst><ceos><c28><c9>delta charlie " 1114 "<rst><ceos><c23><c9>delta " 1115 "charlie<rst><ceos><c22><c9>delta " 1116 "<rst><ceos><c15>" 1117 "<c9>delta<rst><ceos><c14>" 1118 "<c9><rst><ceos><c9>" 1119 "<c9>delta<rst><ceos><c14>" 1120 "<c9>charlie<rst><ceos><c16>" 1121 "<c9>bravo<rst><ceos><c14>" 1122 "<c9>alpha<rst><ceos><c14>" 1123 "<c9>alpha " 1124 "<rst><ceos><c15><c9>alpha " 1125 "alpha<rst><ceos><c20><c9>alpha " 1126 "delta<rst><ceos><c20><c9>alpha " 1127 "charlie<rst><ceos><c22><c9>alpha " 1128 "bravo<rst><ceos><c20><c9>alpha bravo " 1129 "<rst><ceos><c21><c9>alpha bravo " 1130 "bravo<rst><ceos><c26><c9>alpha bravo " 1131 "alpha<rst><ceos><c26><c9>alpha bravo " 1132 "delta<rst><ceos><c26><c9>alpha bravo " 1133 "charlie<rst><ceos><c28><c9>alpha bravo charlie " 1134 "<rst><ceos><c29><c9>alpha bravo charlie " 1135 "charlie<rst><ceos><c36><c9>alpha bravo charlie " 1136 "bravo<rst><ceos><c34><c9>alpha bravo charlie " 1137 "alpha<rst><ceos><c34><c9>alpha bravo charlie " 1138 "delta<rst><ceos><c34><c9>alpha bravo charlie delta<rst><ceos><c34>\r\n" 1139 "alpha bravo charlie delta\r\n", 1140 "delta charlie bravo alpha\n" 1141 ) 1142 self_.check_scenario( 1143 "<up><c-w><c-w><backspace><c-a><c-y> <cr><c-d>", 1144 "<c9>charlie delta alpha bravo<rst><ceos><c34><c9>charlie " 1145 "delta alpha <rst><ceos><c29><c9>charlie delta " 1146 "<rst><ceos><c23><c9>charlie " 1147 "delta<rst><ceos><c22><c9>charlie delta<rst><ceos><c9><c9>alpha " 1148 "bravocharlie delta<rst><ceos><c20><c9>alpha bravo charlie " 1149 "delta<rst><ceos><c21><c9>alpha bravo charlie delta<rst><ceos><c34>\r\n" 1150 "alpha bravo charlie delta\r\n", 1151 "charlie delta alpha bravo\n" 1152 ) 1153 self_.check_scenario( 1154 "<up><home><m-d><m-d><del><c-e> <c-y><cr><c-d>", 1155 "<c9>charlie delta alpha bravo<rst><ceos><c34><c9>charlie " 1156 "delta alpha bravo<rst><ceos><c9><c9> delta alpha bravo<rst><ceos><c9><c9> " 1157 "alpha bravo<rst><ceos><c9><c9>alpha bravo<rst><ceos><c9><c9>alpha " 1158 "bravo<rst><ceos><c20><c9>alpha bravo " 1159 "<rst><ceos><c21><c9>alpha bravo charlie " 1160 "delta<rst><ceos><c34><c9>alpha bravo charlie delta<rst><ceos><c34>\r\n" 1161 "alpha bravo charlie delta\r\n", 1162 "charlie delta alpha bravo\n" 1163 ) 1164 self_.check_scenario( 1165 "<up><c-w><backspace><c-w><backspace><c-w><backspace><c-w><backspace><c-w><backspace>" 1166 "<c-w><backspace><c-w><backspace><c-w><backspace><c-w><backspace><c-w><backspace>" 1167 "<c-w><c-y><m-y><m-y><m-y><m-y><m-y><m-y><m-y><m-y><m-y><m-y><cr><c-d>", 1168 "<c9>a b c d e f g h i j k<rst><ceos><c30><c9>a b c d e f g " 1169 "h i j <rst><ceos><c29><c9>a b c d e f g h i " 1170 "j<rst><ceos><c28><c9>a b c d e f g h i " 1171 "<rst><ceos><c27><c9>a b c d e f g h " 1172 "i<rst><ceos><c26><c9>a b c d e f g h " 1173 "<rst><ceos><c25><c9>a b c d e f g " 1174 "h<rst><ceos><c24><c9>a b c d e f g " 1175 "<rst><ceos><c23><c9>a b c d e f g<rst><ceos><c22><c9>a " 1176 "b c d e f <rst><ceos><c21><c9>a b c d e " 1177 "f<rst><ceos><c20><c9>a b c d e <rst><ceos><c19><c9>a b " 1178 "c d e<rst><ceos><c18><c9>a b c d <rst><ceos><c17><c9>a " 1179 "b c d<rst><ceos><c16><c9>a b c <rst><ceos><c15><c9>a b " 1180 "c<rst><ceos><c14><c9>a b <rst><ceos><c13><c9>a " 1181 "b<rst><ceos><c12><c9>a " 1182 "<rst><ceos><c11>" 1183 "<c9>a<rst><ceos><c10>" 1184 "<c9><rst><ceos><c9>" 1185 "<c9>a<rst><ceos><c10>" 1186 "<c9>b<rst><ceos><c10>" 1187 "<c9>c<rst><ceos><c10>" 1188 "<c9>d<rst><ceos><c10>" 1189 "<c9>e<rst><ceos><c10>" 1190 "<c9>f<rst><ceos><c10>" 1191 "<c9>g<rst><ceos><c10>" 1192 "<c9>h<rst><ceos><c10>" 1193 "<c9>i<rst><ceos><c10>" 1194 "<c9>j<rst><ceos><c10>" 1195 "<c9>a<rst><ceos><c10>" 1196 "<c9>a<rst><ceos><c10>\r\n" 1197 "a\r\n", 1198 "a b c d e f g h i j k\n" 1199 ) 1200 def test_yank_last_arg( self_ ): 1201 self_.check_scenario( 1202 "0123<left><left><m-.><m-.><m-.><cr><c-d>", 1203 "<c9><yellow>0<rst><ceos><c10>" 1204 "<c9><yellow>01<rst><ceos><c11>" 1205 "<c9><yellow>012<rst><ceos><c12>" 1206 "<c9><yellow>0123<rst><ceos><c13>" 1207 "<c9><yellow>0123<rst><ceos><c12>" 1208 "<c9><yellow>0123<rst><ceos><c11>" 1209 "<c9><yellow>01<rst>cat<yellow>23<rst><ceos><c14>" 1210 "<c9><yellow>01<rst>trillion<yellow>23<rst><ceos><c19>" 1211 "<c9><yellow>01<rst>twelve<yellow>23<rst><ceos><c17>" 1212 "<c9><yellow>01<rst>twelve<yellow>23<rst><ceos><c19>\r\n" 1213 "01twelve23\r\n", 1214 "one two three\nten eleven twelve\nmillion trillion\ndog cat\n" 1215 ) 1216 self_.check_scenario( 1217 "<up><up><up> <m-.><m-.><cr><c-d>", 1218 "<c9>dog cat<rst><ceos><c16><c9>million trillion<rst><ceos><c25><c9>ten " 1219 "eleven twelve<rst><ceos><c26><c9>ten eleven twelve <rst><ceos><c27><c9>ten " 1220 "eleven twelve cat<rst><ceos><c30><c9>ten eleven twelve " 1221 "trillion<rst><ceos><c35><c9>ten eleven twelve trillion<rst><ceos><c35>\r\n" 1222 "ten eleven twelve trillion\r\n", 1223 "one two three\nten eleven twelve\nmillion trillion\ndog cat\n" 1224 ) 1225 def test_tab_completion_cutoff( self_ ): 1226 self_.check_scenario( 1227 "<tab>n<tab>y<cr><c-d>", 1228 "<c9><rst><ceos><c9>\r\n" 1229 "Display all 9 possibilities? (y or n)\r\n" 1230 "<brightgreen>replxx<rst>> " 1231 "<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n" 1232 "Display all 9 possibilities? (y or n)<ceos>\r\n" 1233 "db hallo hansekogge quetzalcoatl power\r\n" 1234 "hello hans seamann quit\r\n" 1235 "<brightgreen>replxx<rst>> " 1236 "<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n", 1237 command = ReplxxTests._cSample_ + " q1 c3" 1238 ) 1239 self_.check_scenario( 1240 "<tab>n<cr><c-d>", 1241 "<c9><rst><ceos><c9>\r\n" 1242 "Display all 9 possibilities? (y or n)\r\n" 1243 "<brightgreen>replxx<rst>> " 1244 "<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n", 1245 command = ReplxxTests._cSample_ + " q1 c3" 1246 ) 1247 self_.check_scenario( 1248 "<tab><c-c><cr><c-d>", 1249 "<c9><rst><ceos><c9>\r\n" 1250 "Display all 9 possibilities? (y or n)^C\r\n" 1251 "<brightgreen>replxx<rst>> " 1252 "<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n", 1253 command = ReplxxTests._cSample_ + " q1 c3" 1254 ) 1255 self_.check_scenario( 1256 ["<tab>", "<c-c><cr><c-d>"], 1257 "<c9><rst><ceos><c9>\r\n" 1258 "Display all 9 possibilities? (y or n)^C\r\n" 1259 "<brightgreen>replxx<rst>> " 1260 "<c9><rst><ceos><c9><c9><rst><ceos><c9>\r\n", 1261 command = ReplxxTests._cSample_ + " q1 c3 H200" 1262 ) 1263 def test_preload( self_ ): 1264 self_.check_scenario( 1265 "<cr><c-d>", 1266 "<c9>Alice has a cat.<rst><ceos><c25>" 1267 "<c9>Alice has a cat.<rst><ceos><c25>\r\n" 1268 "Alice has a cat.\r\n", 1269 command = ReplxxTests._cSample_ + " q1 'iAlice has a cat.'" 1270 ) 1271 self_.check_scenario( 1272 "<cr><c-d>", 1273 "<c9>Cat eats mice. " 1274 "<rst><ceos><c26><c9>Cat eats mice. " 1275 "<rst><ceos><c26>\r\n" 1276 "Cat eats mice. " 1277 "\r\n", 1278 command = ReplxxTests._cSample_ + " q1 'iCat\teats\tmice.\r\n'" 1279 ) 1280 self_.check_scenario( 1281 "<cr><c-d>", 1282 "<c9>Cat eats mice. " 1283 "<rst><ceos><c26><c9>Cat eats mice. " 1284 "<rst><ceos><c26>\r\n" 1285 "Cat eats mice. " 1286 "\r\n", 1287 command = ReplxxTests._cSample_ + " q1 'iCat\teats\tmice.\r\n\r\n\n\n'" 1288 ) 1289 self_.check_scenario( 1290 "<cr><c-d>", 1291 "<c9>M Alice has a cat.<rst><ceos><c27>" 1292 "<c9>M Alice has a cat.<rst><ceos><c27>\r\n" 1293 "M Alice has a cat.\r\n", 1294 command = ReplxxTests._cSample_ + " q1 'iMAlice has a cat.'" 1295 ) 1296 self_.check_scenario( 1297 "<cr><c-d>", 1298 "<c9>M Alice has a cat.<rst><ceos><c28>" 1299 "<c9>M Alice has a cat.<rst><ceos><c28>\r\n" 1300 "M Alice has a cat.\r\n", 1301 command = ReplxxTests._cSample_ + " q1 'iM\t\t\t\tAlice has a cat.'" 1302 ) 1303 def test_prompt( self_ ): 1304 prompt = "date: now\nrepl> " 1305 self_.check_scenario( 1306 "<up><cr><up><up><cr><c-d>", 1307 "<c7>three<rst><ceos><c12><c7>three<rst><ceos><c12>\r\n" 1308 "three\r\n" 1309 "date: now\r\n" 1310 "repl> " 1311 "<c7>three<rst><ceos><c12><c7>two<rst><ceos><c10><c7>two<rst><ceos><c10>\r\n" 1312 "two\r\n", 1313 command = ReplxxTests._cSample_ + " q1 'p{}'".format( prompt ), 1314 prompt = prompt, 1315 end = prompt + ReplxxTests._end_ 1316 ) 1317 prompt = "repl>\n" 1318 self_.check_scenario( 1319 "a<cr><c-d>", 1320 "<c1>a<rst><ceos><c2><c1>a<rst><ceos><c2>\r\na\r\n", 1321 command = ReplxxTests._cSample_ + " q1 'p{}'".format( prompt ), 1322 prompt = prompt, 1323 end = prompt + ReplxxTests._end_ 1324 ) 1325 def test_long_line( self_ ): 1326 self_.check_scenario( 1327 "<up><c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left>~<c-left><cr><c-d>", 1328 "<c9>ada clojure eiffel fortran groovy java kotlin modula perl python " 1329 "rust sql<rst><ceos><c2><u2><c9>ada clojure eiffel fortran groovy " 1330 "java kotlin modula perl python rust sql<rst><ceos><u1><c39><u1><c9>ada " 1331 "clojure eiffel fortran groovy java kotlin modula perl python rust " 1332 "~sql<rst><ceos><u1><c40><u1><c9>ada clojure eiffel fortran groovy java " 1333 "kotlin modula perl python rust ~sql<rst><ceos><u1><c34><u1><c9>ada clojure " 1334 "eiffel fortran groovy java kotlin modula perl python ~rust " 1335 "~sql<rst><ceos><u1><c35><u1><c9>ada clojure eiffel fortran groovy java " 1336 "kotlin modula perl python ~rust ~sql<rst><ceos><u1><c27><u1><c9>ada clojure " 1337 "eiffel fortran groovy java kotlin modula perl ~python ~rust " 1338 "~sql<rst><ceos><u1><c28><u1><c9>ada clojure eiffel fortran groovy java " 1339 "kotlin modula perl ~python ~rust ~sql<rst><ceos><u1><c22><u1><c9>ada clojure " 1340 "eiffel fortran groovy java kotlin modula ~perl ~python ~rust " 1341 "~sql<rst><ceos><u1><c23><u1><c9>ada clojure eiffel fortran groovy java " 1342 "kotlin modula ~perl ~python ~rust ~sql<rst><ceos><u1><c15><u1><c9>ada " 1343 "clojure eiffel fortran groovy java kotlin ~modula ~perl ~python ~rust " 1344 "~sql<rst><ceos><u1><c16><u1><c9>ada clojure eiffel fortran groovy java " 1345 "kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u1><c8><u1><c9>ada " 1346 "clojure eiffel fortran groovy java ~kotlin ~modula ~perl ~python ~rust " 1347 "~sql<rst><ceos><u1><c9><u1><c9>ada clojure eiffel fortran groovy java " 1348 "~kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u1><c3><u1><c9>ada " 1349 "clojure eiffel fortran groovy ~java ~kotlin ~modula ~perl ~python ~rust " 1350 "~sql<rst><ceos><u1><c4><u1><c9>ada clojure eiffel fortran groovy ~java " 1351 "~kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u2><c36><c9>ada clojure " 1352 "eiffel fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust " 1353 "~sql<rst><ceos><u2><c37><c9>ada clojure eiffel fortran ~groovy ~java ~kotlin " 1354 "~modula ~perl ~python ~rust ~sql<rst><ceos><u2><c28><c9>ada clojure eiffel " 1355 "~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust " 1356 "~sql<rst><ceos><u2><c29><c9>ada clojure eiffel ~fortran ~groovy ~java " 1357 "~kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u2><c21><c9>ada clojure " 1358 "~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust " 1359 "~sql<rst><ceos><u2><c22><c9>ada clojure ~eiffel ~fortran ~groovy ~java " 1360 "~kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u2><c13><c9>ada ~clojure " 1361 "~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust " 1362 "~sql<rst><ceos><u2><c14><c9>ada ~clojure ~eiffel ~fortran ~groovy ~java " 1363 "~kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u2><c9><c9>~ada ~clojure " 1364 "~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust " 1365 "~sql<rst><ceos><u2><c10><c9>~ada ~clojure ~eiffel ~fortran ~groovy ~java " 1366 "~kotlin ~modula ~perl ~python ~rust ~sql<rst><ceos><u2><c9><c9>~ada ~clojure " 1367 "~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python ~rust " 1368 "~sql<rst><ceos><c14>\r\n" 1369 "~ada ~clojure ~eiffel ~fortran ~groovy ~java ~kotlin ~modula ~perl ~python " 1370 "~rust ~sql\r\n", 1371 " ".join( _words_[::3] ) + "\n", 1372 dimensions = ( 10, 40 ) 1373 ) 1374 def test_colors( self_ ): 1375 self_.check_scenario( 1376 "<up><cr><c-d>", 1377 "<c9><black>color_black<rst> <red>color_red<rst> " 1378 "<green>color_green<rst> <brown>color_brown<rst> <blue>color_blue<rst> " 1379 "<magenta>color_magenta<rst> <cyan>color_cyan<rst> " 1380 "<lightgray>color_lightgray<rst> <gray>color_gray<rst> " 1381 "<brightred>color_brightred<rst> <brightgreen>color_brightgreen<rst> " 1382 "<yellow>color_yellow<rst> <brightblue>color_brightblue<rst> " 1383 "<brightmagenta>color_brightmagenta<rst> <brightcyan>color_brightcyan<rst> " 1384 "<white>color_white<rst><ceos><c70><u2><c9><black>color_black<rst> " 1385 "<red>color_red<rst> <green>color_green<rst> <brown>color_brown<rst> " 1386 "<blue>color_blue<rst> <magenta>color_magenta<rst> <cyan>color_cyan<rst> " 1387 "<lightgray>color_lightgray<rst> <gray>color_gray<rst> " 1388 "<brightred>color_brightred<rst> <brightgreen>color_brightgreen<rst> " 1389 "<yellow>color_yellow<rst> <brightblue>color_brightblue<rst> " 1390 "<brightmagenta>color_brightmagenta<rst> <brightcyan>color_brightcyan<rst> " 1391 "<white>color_white<rst><ceos><c70>\r\n" 1392 "color_black color_red color_green color_brown color_blue color_magenta " 1393 "color_cyan color_lightgray color_gray color_brightred color_brightgreen " 1394 "color_yellow color_brightblue color_brightmagenta color_brightcyan " 1395 "color_white\r\n", 1396 "color_black color_red color_green color_brown color_blue color_magenta color_cyan color_lightgray" 1397 " color_gray color_brightred color_brightgreen color_yellow color_brightblue color_brightmagenta color_brightcyan color_white\n" 1398 ) 1399 def test_word_break_characters( self_ ): 1400 self_.check_scenario( 1401 "<up><c-left>x<c-left><c-left>x<c-left><c-left>x<c-left><c-left>x<c-left><c-left>x<c-left><c-left>x<cr><c-d>", 1402 "<c9>one_two three-four five_six " 1403 "seven-eight<rst><ceos><c48><c9>one_two three-four five_six " 1404 "seven-eight<rst><ceos><c43><c9>one_two three-four five_six " 1405 "seven-xeight<rst><ceos><c44><c9>one_two three-four five_six " 1406 "seven-xeight<rst><ceos><c43><c9>one_two three-four five_six " 1407 "seven-xeight<rst><ceos><c37><c9>one_two three-four five_six " 1408 "xseven-xeight<rst><ceos><c38><c9>one_two three-four five_six " 1409 "xseven-xeight<rst><ceos><c37><c9>one_two three-four five_six " 1410 "xseven-xeight<rst><ceos><c28><c9>one_two three-four xfive_six " 1411 "xseven-xeight<rst><ceos><c29><c9>one_two three-four xfive_six " 1412 "xseven-xeight<rst><ceos><c28><c9>one_two three-four xfive_six " 1413 "xseven-xeight<rst><ceos><c23><c9>one_two three-xfour xfive_six " 1414 "xseven-xeight<rst><ceos><c24><c9>one_two three-xfour xfive_six " 1415 "xseven-xeight<rst><ceos><c23><c9>one_two three-xfour xfive_six " 1416 "xseven-xeight<rst><ceos><c17><c9>one_two xthree-xfour xfive_six " 1417 "xseven-xeight<rst><ceos><c18><c9>one_two xthree-xfour xfive_six " 1418 "xseven-xeight<rst><ceos><c17><c9>one_two xthree-xfour xfive_six " 1419 "xseven-xeight<rst><ceos><c9><c9>xone_two xthree-xfour xfive_six " 1420 "xseven-xeight<rst><ceos><c10><c9>xone_two xthree-xfour xfive_six " 1421 "xseven-xeight<rst><ceos><c54>\r\n" 1422 "xone_two xthree-xfour xfive_six xseven-xeight\r\n", 1423 "one_two three-four five_six seven-eight\n", 1424 command = ReplxxTests._cSample_ + " q1 'w \t-'" 1425 ) 1426 self_.check_scenario( 1427 "<up><c-left>x<c-left><c-left>x<c-left><c-left>x<c-left><c-left>x<c-left><c-left>x<c-left><c-left>x<cr><c-d>", 1428 "<c9>one_two three-four five_six " 1429 "seven-eight<rst><ceos><c48><c9>one_two three-four five_six " 1430 "seven-eight<rst><ceos><c37><c9>one_two three-four five_six " 1431 "xseven-eight<rst><ceos><c38><c9>one_two three-four five_six " 1432 "xseven-eight<rst><ceos><c37><c9>one_two three-four five_six " 1433 "xseven-eight<rst><ceos><c33><c9>one_two three-four five_xsix " 1434 "xseven-eight<rst><ceos><c34><c9>one_two three-four five_xsix " 1435 "xseven-eight<rst><ceos><c33><c9>one_two three-four five_xsix " 1436 "xseven-eight<rst><ceos><c28><c9>one_two three-four xfive_xsix " 1437 "xseven-eight<rst><ceos><c29><c9>one_two three-four xfive_xsix " 1438 "xseven-eight<rst><ceos><c28><c9>one_two three-four xfive_xsix " 1439 "xseven-eight<rst><ceos><c17><c9>one_two xthree-four xfive_xsix " 1440 "xseven-eight<rst><ceos><c18><c9>one_two xthree-four xfive_xsix " 1441 "xseven-eight<rst><ceos><c17><c9>one_two xthree-four xfive_xsix " 1442 "xseven-eight<rst><ceos><c13><c9>one_xtwo xthree-four xfive_xsix " 1443 "xseven-eight<rst><ceos><c14><c9>one_xtwo xthree-four xfive_xsix " 1444 "xseven-eight<rst><ceos><c13><c9>one_xtwo xthree-four xfive_xsix " 1445 "xseven-eight<rst><ceos><c9><c9>xone_xtwo xthree-four xfive_xsix " 1446 "xseven-eight<rst><ceos><c10><c9>xone_xtwo xthree-four xfive_xsix " 1447 "xseven-eight<rst><ceos><c54>\r\n" 1448 "xone_xtwo xthree-four xfive_xsix xseven-eight\r\n", 1449 "one_two three-four five_six seven-eight\n", 1450 command = ReplxxTests._cSample_ + " q1 'w \t_'" 1451 ) 1452 def test_no_color( self_ ): 1453 self_.check_scenario( 1454 "<up> X<cr><c-d>", 1455 "<c9>color_black color_red color_green color_brown color_blue " 1456 "color_magenta color_cyan color_lightgray color_gray color_brightred " 1457 "color_brightgreen color_yellow color_brightblue color_brightmagenta " 1458 "color_brightcyan color_white<ceos><c70><u2><c9>color_black color_red " 1459 "color_green color_brown color_blue color_magenta color_cyan color_lightgray " 1460 "color_gray color_brightred color_brightgreen color_yellow color_brightblue " 1461 "color_brightmagenta color_brightcyan color_white " 1462 "<ceos><c71><u2><c9>color_black color_red color_green color_brown color_blue " 1463 "color_magenta color_cyan color_lightgray color_gray color_brightred " 1464 "color_brightgreen color_yellow color_brightblue color_brightmagenta " 1465 "color_brightcyan color_white X<ceos><c72><u2><c9>color_black color_red " 1466 "color_green color_brown color_blue color_magenta color_cyan color_lightgray " 1467 "color_gray color_brightred color_brightgreen color_yellow color_brightblue " 1468 "color_brightmagenta color_brightcyan color_white X<ceos><c72>\r\n" 1469 "color_black color_red color_green color_brown color_blue color_magenta " 1470 "color_cyan color_lightgray color_gray color_brightred color_brightgreen " 1471 "color_yellow color_brightblue color_brightmagenta color_brightcyan " 1472 "color_white X\r\n", 1473 "color_black color_red color_green color_brown color_blue color_magenta color_cyan color_lightgray" 1474 " color_gray color_brightred color_brightgreen color_yellow color_brightblue color_brightmagenta color_brightcyan color_white\n", 1475 command = ReplxxTests._cSample_ + " q1 m1" 1476 ) 1477 def test_backspace_long_line_on_small_term( self_ ): 1478 self_.check_scenario( 1479 "<cr><cr><cr><up><backspace><backspace><backspace><backspace><backspace><backspace><backspace><backspace><cr><c-d>", 1480 "<c9><ceos><c9>\r\n" 1481 "<brightgreen>replxx<rst>> <c9><ceos><c9>\r\n" 1482 "<brightgreen>replxx<rst>> <c9><ceos><c9>\r\n" 1483 "<brightgreen>replxx<rst>> " 1484 "<c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c14><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c13><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c12><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c11><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c10><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c9><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c8><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c7><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c6><u1><c9>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<rst><ceos><c6>\r\n" 1485 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n", 1486 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", 1487 dimensions = ( 10, 40 ) 1488 ) 1489 self_.check_scenario( 1490 "<cr><cr><cr><up><backspace><backspace><backspace><backspace><backspace><backspace><cr><c-d>", 1491 "<c9><ceos><c9>\r\n" 1492 "<brightgreen>replxx<rst>> <c9><ceos><c9>\r\n" 1493 "<brightgreen>replxx<rst>> <c9><ceos><c9>\r\n" 1494 "<brightgreen>replxx<rst>> <c9>a qu ite lo ng li ne of sh ort wo rds wi " 1495 "ll te st cu rs or mo ve me nt<rst><ceos><c39><u1><c9>a qu ite lo " 1496 "ng li ne of sh ort wo rds wi ll te st cu rs or mo ve me " 1497 "n<rst><ceos><c38><u1><c9>a qu ite lo ng li ne of sh ort wo rds wi " 1498 "ll te st cu rs or mo ve me <rst><ceos><c37><u1><c9>a qu ite lo ng " 1499 "li ne of sh ort wo rds wi ll te st cu rs or mo ve " 1500 "me<rst><ceos><c36><u1><c9>a qu ite lo ng li ne of sh ort wo rds " 1501 "wi ll te st cu rs or mo ve m<rst><ceos><c35><u1><c9>a qu ite lo " 1502 "ng li ne of sh ort wo rds wi ll te st cu rs or mo ve " 1503 "<rst><ceos><c34><u1><c9>a qu ite lo ng li ne of sh ort wo rds wi " 1504 "ll te st cu rs or mo ve<rst><ceos><c33><u1><c9>a qu ite lo ng li " 1505 "ne of sh ort wo rds wi ll te st cu rs or mo ve<rst><ceos><c33>\r\n" 1506 "a qu ite lo ng li ne of sh ort wo rds wi ll te st cu rs or mo ve\r\n", 1507 "a qu ite lo ng li ne of sh ort wo rds wi ll te st cu rs or mo ve me nt\n", 1508 dimensions = ( 10, 40 ) 1509 ) 1510 def test_reverse_history_search_on_max_match( self_ ): 1511 self_.check_scenario( 1512 "<up><c-r><cr><c-d>", 1513 "<c9>aaaaaaaaaaaaaaaaaaaaa<rst><ceos><c30><c1><ceos><c1><ceos>(reverse-i-search)`': " 1514 "aaaaaaaaaaaaaaaaaaaaa<c44><c1><ceos><brightgreen>replxx<rst>> " 1515 "aaaaaaaaaaaaaaaaaaaaa<c30><c9>aaaaaaaaaaaaaaaaaaaaa<rst><ceos><c30>\r\n" 1516 "aaaaaaaaaaaaaaaaaaaaa\r\n", 1517 "aaaaaaaaaaaaaaaaaaaaa\n" 1518 ) 1519 def test_no_terminal( self_ ): 1520 res = subprocess.run( [ ReplxxTests._cSample_, "q1" ], input = b"replxx FTW!\n", stdout = subprocess.PIPE, stderr = subprocess.PIPE ) 1521 self_.assertSequenceEqual( res.stdout, b"starting...\nreplxx FTW!\n\nExiting Replxx\n" ) 1522 def test_async_print( self_ ): 1523 self_.check_scenario( 1524 [ "a", "b", "c", "d", "e", "f<cr><c-d>" ], [ 1525 "<c1><ceos>0\r\n" 1526 "<brightgreen>replxx<rst>> " 1527 "<c9><ceos><c9><c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c1><ceos>1\r\n" 1528 "<brightgreen>replxx<rst>> " 1529 "<c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abcd<rst><ceos><c13><c1><ceos>2\r\n" 1530 "<brightgreen>replxx<rst>> " 1531 "<c9>abcd<rst><ceos><c13><c9>abcde<rst><ceos><c14><c9>abcdef<rst><ceos><c15><c9>abcdef<rst><ceos><c15>\r\n" 1532 "abcdef\r\n", 1533 "<c1><ceos>0\r\n" 1534 "<brightgreen>replxx<rst>> " 1535 "<c9>a<rst><ceos><c10><c9>ab<rst><ceos><c11><c1><ceos>1\r\n" 1536 "<brightgreen>replxx<rst>> " 1537 "<c9>ab<rst><ceos><c11><c9>abc<rst><ceos><c12><c9>abcd<rst><ceos><c13><c1><ceos>2\r\n" 1538 "<brightgreen>replxx<rst>> " 1539 "<c9>abcd<rst><ceos><c13><c9>abcde<rst><ceos><c14><c9>abcdef<rst><ceos><c15><c9>abcdef<rst><ceos><c15>\r\n" 1540 "abcdef\r\n", 1541 ], 1542 command = [ ReplxxTests._cxxSample_, "" ], 1543 pause = 0.5 1544 ) 1545 self_.check_scenario( 1546 [ "<up>", "a", "b", "c", "d", "e", "f<cr><c-d>" ], [ 1547 "<c1><ceos>0\r\n" 1548 "<brightgreen>replxx<rst>> <c9><ceos><c9><c9>a very long line of " 1549 "user input, wider then current terminal, the line is wrapped: " 1550 "<rst><ceos><c11><u2><c9>a very long line of user input, wider then current " 1551 "terminal, the line is wrapped: a<rst><ceos><c12><u2><c1><ceos>1\r\n" 1552 "<brightgreen>replxx<rst>> \r\n" 1553 "\r\n" 1554 "<u2><c9>a very long line of user input, wider then current terminal, " 1555 "the line is wrapped: a<rst><ceos><c12><u2><c9>a very long line of user " 1556 "input, wider then current terminal, the line is wrapped: " 1557 "ab<rst><ceos><c13><u2><c9>a very long line of user input, wider then current " 1558 "terminal, the line is wrapped: abc<rst><ceos><c14><u2><c1><ceos>2\r\n" 1559 "<brightgreen>replxx<rst>> \r\n" 1560 "\r\n" 1561 "<u2><c9>a very long line of user input, wider then current terminal, " 1562 "the line is wrapped: abc<rst><ceos><c14><u2><c9>a very long line of user " 1563 "input, wider then current terminal, the line is wrapped: " 1564 "abcd<rst><ceos><c15><u2><c9>a very long line of user input, wider then " 1565 "current terminal, the line is wrapped: abcde<rst><ceos><c16><u2><c1><ceos>3\r\n" 1566 "<brightgreen>replxx<rst>> \r\n" 1567 "\r\n" 1568 "<u2><c9>a very long line of user input, wider then current terminal, " 1569 "the line is wrapped: abcde<rst><ceos><c16><u2><c9>a very long line of user " 1570 "input, wider then current terminal, the line is wrapped: " 1571 "abcdef<rst><ceos><c17><u2><c9>a very long line of user input, wider then " 1572 "current terminal, the line is wrapped: abcdef<rst><ceos><c17>\r\n" 1573 "a very long line of user input, wider then current terminal, the line is " 1574 "wrapped: abcdef\r\n", 1575 "<c1><ceos>0\r\n" 1576 "<brightgreen>replxx<rst>> <c9><ceos><c9><c9>a very long line of user input, " 1577 "wider then current terminal, the line is wrapped: <rst><ceos><c11><u2><c9>a " 1578 "very long line of user input, wider then current terminal, the line is " 1579 "wrapped: a<rst><ceos><c12><u2><c1><ceos>1\r\n" 1580 "<brightgreen>replxx<rst>> \r\n" 1581 "\r\n" 1582 "<u2><c9>a very long line of user input, wider then current terminal, the " 1583 "line is wrapped: a<rst><ceos><c12><u2><c9>a very long line of user input, " 1584 "wider then current terminal, the line is wrapped: " 1585 "ab<rst><ceos><c13><u2><c9>a very long line of user input, wider then current " 1586 "terminal, the line is wrapped: abc<rst><ceos><c14><u2><c1><ceos>2\r\n" 1587 "<brightgreen>replxx<rst>> \r\n" 1588 "\r\n" 1589 "<u2><c9>a very long line of user input, wider then current terminal, the " 1590 "line is wrapped: abc<rst><ceos><c14><u2><c9>a very long line of user input, " 1591 "wider then current terminal, the line is wrapped: " 1592 "abcd<rst><ceos><c15><u2><c1><ceos>3\r\n" 1593 "<brightgreen>replxx<rst>> \r\n" 1594 "\r\n" 1595 "<u2><c9>a very long line of user input, wider then current terminal, the " 1596 "line is wrapped: abcd<rst><ceos><c15><u2><c9>a very long line of user input, " 1597 "wider then current terminal, the line is wrapped: " 1598 "abcde<rst><ceos><c16><u2><c9>a very long line of user input, wider then " 1599 "current terminal, the line is wrapped: abcdef<rst><ceos><c17><u2><c9>a very " 1600 "long line of user input, wider then current terminal, the line is wrapped: " 1601 "abcdef<rst><ceos><c17>\r\n" 1602 "a very long line of user input, wider then current terminal, the line is " 1603 "wrapped: abcdef\r\n", 1604 "<c1><ceos>0\r\n" 1605 "<brightgreen>replxx<rst>> <c9>a very long line of user input, wider then " 1606 "current terminal, the line is wrapped: <rst><ceos><c11><u2><c9>a very long " 1607 "line of user input, wider then current terminal, the line is wrapped: " 1608 "a<rst><ceos><c12><u2><c1><ceos>1\r\n" 1609 "<brightgreen>replxx<rst>> \r\n" 1610 "\r\n" 1611 "<u2><c9>a very long line of user input, wider then current terminal, the " 1612 "line is wrapped: a<rst><ceos><c12><u2><c9>a very long line of user input, " 1613 "wider then current terminal, the line is wrapped: " 1614 "ab<rst><ceos><c13><u2><c9>a very long line of user input, wider then current " 1615 "terminal, the line is wrapped: abc<rst><ceos><c14><u2><c1><ceos>2\r\n" 1616 "<brightgreen>replxx<rst>> \r\n" 1617 "\r\n" 1618 "<u2><c9>a very long line of user input, wider then current terminal, the " 1619 "line is wrapped: abc<rst><ceos><c14><u2><c9>a very long line of user input, " 1620 "wider then current terminal, the line is wrapped: " 1621 "abcd<rst><ceos><c15><u2><c1><ceos>3\r\n" 1622 "<brightgreen>replxx<rst>> \r\n" 1623 "\r\n" 1624 "<u2><c9>a very long line of user input, wider then current terminal, the " 1625 "line is wrapped: abcd<rst><ceos><c15><u2><c9>a very long line of user input, " 1626 "wider then current terminal, the line is wrapped: " 1627 "abcde<rst><ceos><c16><u2><c9>a very long line of user input, wider then " 1628 "current terminal, the line is wrapped: abcdef<rst><ceos><c17><u2><c9>a very " 1629 "long line of user input, wider then current terminal, the line is wrapped: " 1630 "abcdef<rst><ceos><c17>\r\n" 1631 "a very long line of user input, wider then current terminal, the line is " 1632 "wrapped: abcdef\r\n" 1633 ], 1634 "a very long line of user input, wider then current terminal, the line is wrapped: \n", 1635 command = [ ReplxxTests._cxxSample_, "" ], 1636 dimensions = ( 10, 40 ), 1637 pause = 0.5 1638 ) 1639 def test_async_emulate_key_press( self_ ): 1640 self_.check_scenario( 1641 [ "a", "b", "c", "d", "e", "f<cr><c-d>" ], [ 1642 "<c9><yellow>1<rst><ceos><c10><c9><yellow>1<rst>a" 1643 "<rst><ceos><c11><c9><yellow>1<rst>ab<rst><ceos><c12><c9><yellow>1<rst>ab" 1644 "<yellow>2<rst><ceos><c13><c9><yellow>1<rst>ab<yellow>2" 1645 "<rst>c<rst><ceos><c14><c9><yellow>1<rst>ab<yellow>2" 1646 "<rst>cd<rst><ceos><c15><c9><yellow>1<rst>ab<yellow>2<rst>cd<yellow>3" 1647 "<rst><ceos><c16><c9><yellow>1<rst>ab<yellow>2<rst>cd<yellow>3<rst>e" 1648 "<rst><ceos><c17><c9><yellow>1<rst>ab<yellow>2<rst>cd<yellow>3<rst>ef" 1649 "<rst><ceos><c18><c9><yellow>1<rst>ab<yellow>2<rst>cd<yellow>3<rst>ef<rst><ceos><c18>\r\n" 1650 "1ab2cd3ef\r\n", 1651 "<c9><yellow>1<rst>a<rst><ceos><c11><c9><yellow>1<rst>ab" 1652 "<rst><ceos><c12><c9><yellow>1<rst>ab<yellow>2<rst><ceos><c13><c9><yellow>1<rst>ab" 1653 "<yellow>2<rst>c<rst><ceos><c14><c9><yellow>1<rst>ab<yellow>2<rst>cd<rst><ceos><c15>" 1654 "<c9><yellow>1<rst>ab<yellow>2<rst>cd<yellow>3<rst><ceos><c16><c9><yellow>1<rst>ab" 1655 "<yellow>2<rst>cd<yellow>3<rst>e<rst><ceos><c17><c9><yellow>1<rst>ab<yellow>2<rst>cd" 1656 "<yellow>3<rst>ef<rst><ceos><c18><c9><yellow>1<rst>ab<yellow>2<rst>cd<yellow>3<rst>ef<rst><ceos><c18>\r\n" 1657 "1ab2cd3ef\r\n" 1658 ], 1659 command = [ ReplxxTests._cxxSample_, "123456" ], 1660 pause = 0.5 1661 ) 1662 def test_special_keys( self_ ): 1663 self_.check_scenario( 1664 "<f1><f2><f3><f4><f5><f6><f7><f8><f9><f10><f11><f12>" 1665 "<s-f1><s-f2><s-f3><s-f4><s-f5><s-f6><s-f7><s-f8><s-f9><s-f10><s-f11><s-f12>" 1666 "<c-f1><c-f2><c-f3><c-f4><c-f5><c-f6><c-f7><c-f8><c-f9><c-f10><c-f11><c-f12>" 1667 "<s-tab><s-left><s-right><s-up><s-down>" 1668 "<s-home><s-end><c-home><c-end><c-pgup><c-pgdown>" 1669 "<cr><c-d>", 1670 "<c1><ceos><F1>\r\n" 1671 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F2>\r\n" 1672 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F3>\r\n" 1673 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F4>\r\n" 1674 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F5>\r\n" 1675 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F6>\r\n" 1676 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F7>\r\n" 1677 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F8>\r\n" 1678 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F9>\r\n" 1679 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F10>\r\n" 1680 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F11>\r\n" 1681 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><F12>\r\n" 1682 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F1>\r\n" 1683 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F2>\r\n" 1684 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F3>\r\n" 1685 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F4>\r\n" 1686 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F5>\r\n" 1687 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F6>\r\n" 1688 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F7>\r\n" 1689 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F8>\r\n" 1690 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F9>\r\n" 1691 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F10>\r\n" 1692 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F11>\r\n" 1693 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-F12>\r\n" 1694 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F1>\r\n" 1695 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F2>\r\n" 1696 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F3>\r\n" 1697 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F4>\r\n" 1698 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F5>\r\n" 1699 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F6>\r\n" 1700 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F7>\r\n" 1701 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F8>\r\n" 1702 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F9>\r\n" 1703 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F10>\r\n" 1704 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F11>\r\n" 1705 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-F12>\r\n" 1706 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-Tab>\r\n" 1707 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-Left>\r\n" 1708 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-Right>\r\n" 1709 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-Up>\r\n" 1710 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-Down>\r\n" 1711 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-Home>\r\n" 1712 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><S-End>\r\n" 1713 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-Home>\r\n" 1714 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-End>\r\n" 1715 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-PgUp>\r\n" 1716 "<brightgreen>replxx<rst>> <c9><ceos><c9><c1><ceos><C-PgDn>\r\n" 1717 "<brightgreen>replxx<rst>> <c9><ceos><c9><c9><ceos><c9>\r\n" 1718 ) 1719 def test_overwrite_mode( self_ ): 1720 self_.check_scenario( 1721 "<up><home><right><right>XYZ<ins>012<ins>345<cr><c-d>", 1722 "<c9>abcdefgh<rst><ceos><c17><c9>abcdefgh<rst><ceos><c9>" 1723 "<c9>abcdefgh<rst><ceos><c10><c9>abcdefgh<rst><ceos><c11>" 1724 "<c9>abXcdefgh<rst><ceos><c12><c9>abXYcdefgh<rst><ceos><c13>" 1725 "<c9>abXYZcdefgh<rst><ceos><c14><c9>abXYZ<yellow>0<rst>defgh<rst><ceos><c15>" 1726 "<c9>abXYZ<yellow>01<rst>efgh<rst><ceos><c16><c9>abXYZ<yellow>012<rst>fgh<rst><ceos><c17>" 1727 "<c9>abXYZ<yellow>0123<rst>fgh<rst><ceos><c18><c9>abXYZ<yellow>01234<rst>fgh<rst><ceos><c19>" 1728 "<c9>abXYZ<yellow>012345<rst>fgh<rst><ceos><c20><c9>abXYZ<yellow>012345<rst>fgh<rst><ceos><c23>\r\n" 1729 "abXYZ012345fgh\r\n", 1730 "abcdefgh\n" 1731 ) 1732 def test_verbatim_insert( self_ ): 1733 self_.check_scenario( 1734 ["<c-v>", rapid( "<ins>" ), "<cr><c-d>"], 1735 "<c9>^[<brightmagenta>[<yellow>2<rst>~<rst><ceos><c14><c9>^[<brightmagenta>[<yellow>2<rst>~<rst><ceos><c14>\r\n" 1736 "<ins-key>\r\n" 1737 ) 1738 def test_hint_delay( self_ ): 1739 self_.check_scenario( 1740 ["han", "<cr><c-d>"], 1741 "<c9>h<rst><ceos><c10><c9>ha<rst><ceos><c11><c9>han<rst><ceos><c12><c9>han<rst><ceos>\r\n" 1742 " <gray>hans<rst>\r\n" 1743 " <gray>hansekogge<rst><u2><c12><c9>han<rst><ceos><c12>\r\n" 1744 "han\r\n", 1745 command = [ ReplxxTests._cSample_, "q1", "H200" ] 1746 ) 1747 def test_complete_next( self_ ): 1748 self_.check_scenario( 1749 "<up><c-n><c-n><c-p><c-p><c-p><cr><c-d>", 1750 "<c9>color_<rst><ceos>\r\n" 1751 " <gray>color_black<rst>\r\n" 1752 " <gray>color_red<rst>\r\n" 1753 " " 1754 "<gray>color_green<rst><u3><c15><c9><black>color_black<rst><ceos><c20>" 1755 "<c9><red>color_red<rst><ceos><c18><c9><black>color_black<rst><ceos><c20><c9>color_<rst><ceos>\r\n" 1756 1757 " <gray>color_black<rst>\r\n" 1758 " <gray>color_red<rst>\r\n" 1759 " " 1760 "<gray>color_green<rst><u3><c15><c9><lightgray>color_normal<rst><ceos><c21><c9><lightgray>color_normal<rst><ceos><c21>\r\n" 1761 "color_normal\r\n", 1762 "color_\n" 1763 ) 1764 self_.check_scenario( 1765 "l<c-n><c-n><c-p><c-p><cr><c-d>", 1766 "<c9>l<rst><ceos>\r\n" 1767 " <gray>lc_ctype<rst>\r\n" 1768 " <gray>lc_time<rst>\r\n" 1769 " <gray>lc_messages<rst><u3><c10><c9>lc_<rst><ceos>\r\n" 1770 " <gray>lc_ctype<rst>\r\n" 1771 " <gray>lc_time<rst>\r\n" 1772 " " 1773 "<gray>lc_messages<rst><u3><c12><c9>lc_ctype<rst><ceos><c17><c9>lc_time<rst><ceos><c16><c9>lc_ctype<rst><ceos><c17><c9>lc_<rst><ceos>\r\n" 1774 " <gray>lc_ctype<rst>\r\n" 1775 " <gray>lc_time<rst>\r\n" 1776 " <gray>lc_messages<rst><u3><c12><c9>lc_<rst><ceos><c12>\r\n" 1777 "lc_\r\n", 1778 command = [ ReplxxTests._cSample_, "xlc_ctype,lc_time,lc_messages,zoom", "I1", "q1" ] 1779 ) 1780 self_.check_scenario( 1781 "l<c-n><c-n><c-p><c-p><cr><c-d>", 1782 "<c9>l<rst><ceos>\r\n" 1783 " <gray>lc_ctype<rst>\r\n" 1784 " <gray>lc_time<rst>\r\n" 1785 " <gray>lc_messages<rst><u3><c10><c9>lc_<rst><ceos>\r\n" 1786 " <gray>lc_ctype<rst>\r\n" 1787 " <gray>lc_time<rst>\r\n" 1788 " " 1789 "<gray>lc_messages<rst><u3><c12><c9>lc_ctype<rst><ceos><c17><c9>lc_<rst><ceos>\r\n" 1790 " <gray>lc_ctype<rst>\r\n" 1791 " <gray>lc_time<rst>\r\n" 1792 " " 1793 "<gray>lc_messages<rst><u3><c12><c9>lc_messages<rst><ceos><c20><c9>lc_messages<rst><ceos><c20>\r\n" 1794 "lc_messages\r\n", 1795 command = [ ReplxxTests._cSample_, "xlc_ctype,lc_time,lc_messages,zoom", "I0", "q1" ] 1796 ) 1797 def test_disabled_handlers( self_ ): 1798 self_.check_scenario( 1799 "<up><left><backspace>4<cr><c-d>", 1800 "<c9>(+ 1 2)<rst><ceos><c16><c9><brightred>(<rst>+ 1 " 1801 "2)<rst><ceos><c15><c9><brightred>(<rst>+ 1 " 1802 ")<rst><ceos><c14><c9><brightred>(<rst>+ 1 " 1803 "4)<rst><ceos><c15><c9><brightred>(<rst>+ 1 4)<rst><ceos><c16>\r\n" 1804 "thanks for the input: (+ 1 4)\r\n", 1805 "(+ 1 2)\r\n", 1806 command = [ ReplxxTests._cSample_, "N", "S" ] 1807 ) 1808 def test_state_manipulation( self_ ): 1809 self_.check_scenario( 1810 "<up><f2>~<cr><c-d>", 1811 "<c9>replxx<rst><ceos><c15><c9>REPLXX<rst><ceos><c12><c9>REP~LXX<rst><ceos><c13><c9>REP~LXX<rst><ceos><c16>\r\n" 1812 "REP~LXX\r\n", 1813 "replxx\n", 1814 command = [ ReplxxTests._cSample_, "q1" ] 1815 ) 1816 def test_modify_callback( self_ ): 1817 self_.check_scenario( 1818 "<up><home><right><right>*<cr><c-d>", 1819 "<c9>abcd<brightmagenta>12<rst><ceos><c15><c9>abcd<brightmagenta>12<rst><ceos><c9>" 1820 "<c9>abcd<brightmagenta>12<rst><ceos><c10><c9>abcd<brightmagenta>12<rst><ceos><c11>" 1821 "<c9>ababcd<brightmagenta>12<rst>cd<brightmagenta>12<rst><ceos><c15>" 1822 "<c9>ababcd<brightmagenta>12<rst>cd<brightmagenta>12<rst><ceos><c21>\r\n" 1823 "ababcd12cd12\r\n", 1824 "abcd12\n", 1825 command = [ ReplxxTests._cSample_, "q1", "M1" ] 1826 ) 1827 def test_paste( self_ ): 1828 self_.check_scenario( 1829 rapid( "abcdef<cr><c-d>" ), 1830 "<c9>a<rst><ceos><c10><c9>abcdef<rst><ceos><c15>\r\nabcdef\r\n" 1831 ) 1832 def test_history_merge( self_ ): 1833 with open( "replxx_history_alt.txt", "w" ) as f: 1834 f.write( 1835 "### 0000-00-00 00:00:00.001\n" 1836 "one\n" 1837 "### 0000-00-00 00:00:00.003\n" 1838 "three\n" 1839 "### 0000-00-00 00:00:00.005\n" 1840 "other\n" 1841 "### 0000-00-00 00:00:00.009\n" 1842 "same\n" 1843 "### 0000-00-00 00:00:00.017\n" 1844 "seven\n" 1845 ) 1846 f.close() 1847 self_.check_scenario( 1848 "<up><cr><c-d>", 1849 "<c9><brightmagenta>.<rst>merge<rst><ceos><c15><c9><brightmagenta>.<rst>merge<rst><ceos><c15>\r\n", 1850 "### 0000-00-00 00:00:00.002\n" 1851 "two\n" 1852 "### 0000-00-00 00:00:00.004\n" 1853 "four\n" 1854 "### 0000-00-00 00:00:00.006\n" 1855 "same\n" 1856 "### 0000-00-00 00:00:00.008\n" 1857 "other\n" 1858 "### 0000-00-00 00:00:00.018\n" 1859 ".merge\n" 1860 ) 1861 with open( "replxx_history_alt.txt", "r" ) as f: 1862 data = f.read() 1863 expected = ( 1864 "### 0000-00-00 00:00:00.001\n" 1865 "one\n" 1866 "### 0000-00-00 00:00:00.002\n" 1867 "two\n" 1868 "### 0000-00-00 00:00:00.003\n" 1869 "three\n" 1870 "### 0000-00-00 00:00:00.004\n" 1871 "four\n" 1872 "### 0000-00-00 00:00:00.008\n" 1873 "other\n" 1874 "### 0000-00-00 00:00:00.009\n" 1875 "same\n" 1876 "### 0000-00-00 00:00:00.017\n" 1877 "seven\n" 1878 "### " 1879 ) 1880 self_.assertSequenceEqual( data[:-31], expected ) 1881 self_.assertSequenceEqual( data[-7:], ".merge\n" ) 1882 def test_bracketed_paste( self_ ): 1883 self_.check_scenario( 1884 "a0<paste-pfx>b1c2d3e<paste-sfx>4f<cr><c-d>", 1885 "<c9>a<rst><ceos><c10>" 1886 "<c9>a<brightmagenta>0<rst><ceos><c11>" 1887 "<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<rst><ceos><c18>" 1888 "<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<brightmagenta>4<rst><ceos><c19>" 1889 "<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<brightmagenta>4<rst>f<rst><ceos><c20>" 1890 "<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<brightmagenta>4<rst>f<rst><ceos><c20>\r\n" 1891 "a0b1c2d3e4f\r\n", 1892 command = [ ReplxxTests._cSample_, "q1" ] 1893 ) 1894 self_.check_scenario( 1895 "a0<paste-pfx>b1c2d3e<paste-sfx>4f<cr><c-d>", 1896 "<c9>a<rst><ceos><c10>" 1897 "<c9>a<brightmagenta>0<rst><ceos><c11>" 1898 "<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<rst><ceos><c18>" 1899 "<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<brightmagenta>4<rst><ceos><c19>" 1900 "<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<brightmagenta>4<rst>f<rst><ceos><c20>" 1901 "<c9>a<brightmagenta>0<rst>b<brightmagenta>1<rst>c<brightmagenta>2<rst>d<brightmagenta>3<rst>e<brightmagenta>4<rst>f<rst><ceos><c20>\r\n" 1902 "a0b1c2d3e4f\r\n", 1903 command = [ ReplxxTests._cSample_, "q1", "B" ] 1904 ) 1905 self_.check_scenario( 1906 "a0<left><paste-pfx>/eb<paste-sfx><cr><paste-pfx>/db<paste-sfx><cr><paste-pfx>x<paste-sfx><cr><c-d>", 1907 "<c9>a<rst><ceos><c10><c9>a<brightmagenta>0<rst><ceos><c11><c9>a<brightmagenta>0<rst><ceos><c10>" 1908 "<c9>a/eb<brightmagenta>0<rst><ceos><c13><c9>a/eb<brightmagenta>0<rst><ceos><c14>\r\n" 1909 "a/eb0\r\n" 1910 "<brightgreen>replxx<rst>> <c9>/db<rst><ceos><c12><c9>/db<rst><ceos><c12>\r\n" 1911 "/db\r\n" 1912 "<brightgreen>replxx<rst>> <c9>x<rst><ceos><c10><c9>x<rst><ceos><c10>\r\n" 1913 "x\r\n", 1914 command = [ ReplxxTests._cSample_, "q1" ] 1915 ) 1916 1917def parseArgs( self, func, argv ): 1918 global verbosity 1919 res = func( self, argv ) 1920 verbosity = self.verbosity 1921 return res 1922 1923if __name__ == "__main__": 1924 pa = unittest.TestProgram.parseArgs 1925 unittest.TestProgram.parseArgs = lambda self, argv: parseArgs( self, pa, argv ) 1926 unittest.main() 1927 1928