def test_getitem(): assert op.getitem(['a', 'b', 'c'], 2) == 'c' assert op.getitem(['a', 'b'], 2, 'c') == 'c' ran = range(10) ran_copy = deepcopy(ran) assert op.getitem(ran, 2) == 2 assert ran == ran_copy assert op.getitem({'a':1, 'b':2}, 'b') == 2
def test_captcha(): cmd = '{0} -m minghu6.tools.captcha --help'.format(pypath) info_lines, err_lines = exec_cmd(cmd) assert getitem(err_lines, 0, 'failed') == '' assert info_lines
def test_text_editor(): cmd = '{0} -m minghu6.tools.text_editor --help'.format(pypath) info_lines, err_lines = exec_cmd(cmd) assert getitem(err_lines, 0, 'failed') == '' assert info_lines
def test_youtube(): cmd = '{0} -m minghu6.tools.youtube --help'.format(pypath) info_lines, err_lines = exec_cmd(cmd) assert getitem(err_lines, 0, 'failed') == '' assert info_lines
def test_getitem_with_exception_key(): op.getitem({}, 'key')
def test_getitem_with_exception_index(): op.getitem(range(5), 5)
def test_ffmpeg_fix(): cmd = '{0} -m minghu6.tools.ffmpeg_fix --help'.format(pypath) info_lines, err_lines = exec_cmd(cmd) assert getitem(err_lines, 0, 'failed') == '' assert info_lines
def interactive(): echo(getitem(sys.argv, 1, ''))
import sys from minghu6.algs.operator import getitem __all__ = ['echo'] def echo(s): # sys.stdout.write(s) print(s) if __name__ == '__main__': echo(getitem(sys.argv, 1, ''))