;
"Ic            	   @   s   d  Z  d d l Z d d l Z d d l Z d d l Z d d l m Z Gd   d e j  Z d d  Z
 d   Z e d k o) d	 e j k o e d
  q e
   n d S(   u@   
Test script for the 'cmd' module
Original by Michael Schneider
i    N(   u   StringIOc             B   s\   |  Ee  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	 S(
   u  
    Instance the sampleclass:
    >>> mycmd = samplecmdclass()

    Test for the function parseline():
    >>> mycmd.parseline("")
    (None, None, '')
    >>> mycmd.parseline("?")
    ('help', '', 'help ')
    >>> mycmd.parseline("?help")
    ('help', 'help', 'help help')
    >>> mycmd.parseline("!")
    ('shell', '', 'shell ')
    >>> mycmd.parseline("!command")
    ('shell', 'command', 'shell command')
    >>> mycmd.parseline("func")
    ('func', '', 'func')
    >>> mycmd.parseline("func arg1")
    ('func', 'arg1', 'func arg1')


    Test for the function onecmd():
    >>> mycmd.onecmd("")
    >>> mycmd.onecmd("add 4 5")
    9
    >>> mycmd.onecmd("")
    9
    >>> mycmd.onecmd("test")
    *** Unknown syntax: test

    Test for the function emptyline():
    >>> mycmd.emptyline()
    *** Unknown syntax: test

    Test for the function default():
    >>> mycmd.default("default")
    *** Unknown syntax: default

    Test for the function completedefault():
    >>> mycmd.completedefault()
    This is the completedefault methode
    >>> mycmd.completenames("a")
    ['add']

    Test for the function completenames():
    >>> mycmd.completenames("12")
    []
    >>> mycmd.completenames("help")
    ['help', 'help']

    Test for the function complete_help():
    >>> mycmd.complete_help("a")
    ['add']
    >>> mycmd.complete_help("he")
    ['help', 'help']
    >>> mycmd.complete_help("12")
    []

    Test for the function do_help():
    >>> mycmd.do_help("testet")
    *** No help on testet
    >>> mycmd.do_help("add")
    help text for add
    >>> mycmd.onecmd("help add")
    help text for add
    >>> mycmd.do_help("")
    <BLANKLINE>
    Documented commands (type help <topic>):
    ========================================
    add
    <BLANKLINE>
    Undocumented commands:
    ======================
    exit  help  shell
    <BLANKLINE>

    Test for the function print_topics():
    >>> mycmd.print_topics("header", ["command1", "command2"], 2 ,10)
    header
    ======
    command1
    command2
    <BLANKLINE>

    Test for the function columnize():
    >>> mycmd.columnize([str(i) for i in range(20)])
    0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19
    >>> mycmd.columnize([str(i) for i in range(20)], 10)
    0  7   14
    1  8   15
    2  9   16
    3  10  17
    4  11  18
    5  12  19
    6  13

    This is a interactive test, put some commands in the cmdqueue attribute
    and let it execute
    This test includes the preloop(), postloop(), default(), emptyline(),
    parseline(), do_help() functions
    >>> mycmd.use_rawinput=0
    >>> mycmd.cmdqueue=["", "add", "add 4 5", "help", "help add","exit"]
    >>> mycmd.cmdloop()
    Hello from preloop
    help text for add
    *** invalid number of arguments
    9
    <BLANKLINE>
    Documented commands (type help <topic>):
    ========================================
    add
    <BLANKLINE>
    Undocumented commands:
    ======================
    exit  help  shell
    <BLANKLINE>
    help text for add
    Hello from postloop
    c             C   s   t  d  d  S(   Nu   Hello from preloop(   u   print(   u   self(    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu   preloop   s    c             C   s   t  d  d  S(   Nu   Hello from postloop(   u   print(   u   self(    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu   postloop   s    c             G   s   t  d  d  S(   Nu#   This is the completedefault methode(   u   print(   u   selfu   ignored(    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu   completedefault   s    c             C   s   t  d  d  S(   Nu   complete command(   u   print(   u   self(    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu   complete_command   s    c             C   s   d  S(   N(    (   u   self(    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu   do_shell   s    c          
   C   s   | j    } t |  d k o t d  d  Sy d   | D } Wn" t k
 o t d  d  SYn Xt | d | d  d  S(   Ni   u   *** invalid number of argumentsc             S   s!   g  } |  ] } | t  |  q
 S(    (   u   int(   u   .0u   _[1]u   i(    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu
   <listcomp>   s    u   *** arguments should be numbersi    i   (   u   splitu   lenu   printu
   ValueError(   u   selfu   su   l(    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu   do_add   s    


c             C   s   t  d  d  S(   Nu   help text for add(   u   print(   u   self(    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu   help_add   s    
c             C   s   d S(   NT(   u   True(   u   selfu   arg(    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu   do_exit   s    N(   u   __name__u
   __module__u   __doc__u   preloopu   postloopu   completedefaultu   complete_commandu   do_shellu   do_addu   help_addu   do_exit(   u
   __locals__(    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu   samplecmdclass   s   
w							u   samplecmdclassc             C   s*   d d l  m } m } | j | |   d  S(   Ni    (   u   supportu   test_cmd(   u   testu   supportu   test_cmdu   run_doctest(   u   verboseu   supportu   test_cmd(    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu	   test_main   s    c             C   sm   t  j d t j t j g d d d d  } | j d  | j   } t d  | j d d d	 d d
 |   d  S(   Nu
   ignoredirsu   tracei    u   counti   u   reload(cmd);test_main()u   Writing coverage results...u   show_missingu   summaryu   coverdirT(
   u   traceu   Traceu   sysu   prefixu   exec_prefixu   runu   resultsu   printu   write_resultsu   True(   u   coverdiru   traceru   r(    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu   test_coverage   s    
u   __main__u   -cu   /tmp/cmd.cover(   u   __doc__u   cmdu   sysu   traceu   reu   iou   StringIOu   Cmdu   samplecmdclassu   Noneu	   test_mainu   test_coverageu   __name__u   argv(    (    (    u*   /mit/python/lib/python3.0/test/test_cmd.pyu   <module>   s   	