Пример #1
0
def test_read():
    """
    To test command_read method
    :return: Test result
    """
    # test case 1: read a file into editor
    print("Testing read......")
    test_case_1 = Editor()
    test_case_1.command_read('text.txt')

    assert test_case_1 is not None, "Read method does not work as expect!"
    print("Test 1 succeed!")
Пример #2
0
def test_print():
    """
    To test command_print method
    :return: Test result
    """
    print("Testing print......")
    test_case = Editor()

    # test case 1: print a line of text in the editor
    test_case.command_read('text.txt')
    try:
        test_case.command_print(0)
    except:
        print("method does not work as expect!")
Пример #3
0
def test_insert():
    """
    To test command_insert method
    :return: Test result
    """
    print("Testing insert......")
    test_case = Editor()

    # test case 1: insert a text into the list
    test_case.command_read('text.txt')
    test_case.command_insert(1)
    assert test_case.list[
        1] == 'hello', "Insert method does not work as expect!"
    test_case.command_print('')
Пример #4
0
def test_delete():
    """
    To test command_delete method
    :return: Test result
    """
    print("Testing delete......")
    test_case = Editor()

    # case 1 : delete a line of text in the editor
    test_case.command_read('text.txt')
    origin_text = test_case.list[0]
    test_case.command_delete('0')
    final_text = test_case.list[0]

    assert origin_text != final_text, "Delete method does not work!"
Пример #5
0
def test_read_fail():

    # test case 2 : read a file that does not exist
    test_case_2 = Editor()
    test_case_2.command_read('N/A.text')