Skip to content

Too long filenames cause test failure #57

@juntuu

Description

@juntuu

Description

This demonstrates failure mode of some tests, where the temporary directory path generated by pytest is too long to fully fit into the header. (encountered on MacOS)

This leads to the assertions on the visible contents to fail. For example: looking for the modified indicator ' *', or exact match on the filename or particular part of it.

Example breaking test

from testing.runner import and_exit

def test_failing_too_long_filename(run, tmpdir):
    path = str(tmpdir.join('file' * 20 + '.txt'))
    assert len(path) > 80
    with run(path) as h, and_exit(h):
        h.press('a')
        h.await_text(' *')

The top of the resulting screen:

===============================================================================
 babi v0.0.7 lefilefilefilefilefilefilefilefilefilefilefilefilefilefilefilefilef
a

Possible solution

The filename should probably be truncated in a consistent manner, without hiding the indicator or other such information.

This is also what nano does:

  GNU nano 2.0.6 File: ...filefilefilefilefilefile.txt Modified

a

Currently failing tests

Running with pytest tests/ -k fake:

=============================================== short test summary info ===============================================
FAILED tests/features/cut_uncut_test.py::test_cut_and_uncut[fake] - AssertionError: expected: ' *'
FAILED tests/features/cut_uncut_test.py::test_selection_cut_uncut[fake] - AssertionError: expected: ' *'
FAILED tests/features/cut_uncut_test.py::test_selection_cut_uncut_backwards_select[fake] - AssertionError: expected:...
FAILED tests/features/cut_uncut_test.py::test_selection_cut_uncut_within_line[fake] - AssertionError: expected: ' *'
FAILED tests/features/multiple_files_test.py::test_multiple_files[fake] - AssertionError: expected: 'file_a'
FAILED tests/features/multiple_files_test.py::test_multiple_files_close_from_beginning[fake] - AssertionError: expec...
FAILED tests/features/multiple_files_test.py::test_multiple_files_close_from_end[fake] - AssertionError: expected: '...
FAILED tests/features/replace_test.py::test_replace_actual_contents[fake] - AssertionError: expected: ' *'
FAILED tests/features/save_test.py::test_mixed_newlines[fake] - AssertionError: expected: 'f *'
FAILED tests/features/save_test.py::test_modify_file_with_windows_newlines[fake] - AssertionError: expected: '*'
FAILED tests/features/save_test.py::test_saving_file_with_multiple_lines_at_end_maintains_those[fake] - AssertionErr...
FAILED tests/features/save_test.py::test_not_a_file[fake] - AssertionError: expected: "d' is not a file"
FAILED tests/features/save_test.py::test_save_on_exit[fake] - AssertionError: expected: 'enter filename: /private/va...
FAILED tests/features/text_editing_test.py::test_backspace_joins_lines[fake] - AssertionError: expected: 'f *'
FAILED tests/features/text_editing_test.py::test_backspace_deletes_text[fake-BSpace] - AssertionError: expected: 'f *'
FAILED tests/features/text_editing_test.py::test_backspace_deletes_text[fake-^H] - AssertionError: expected: 'f *'
FAILED tests/features/text_editing_test.py::test_delete_removes_character_afterwards[fake] - AssertionError: expecte...
FAILED tests/features/text_editing_test.py::test_delete_at_end_of_line[fake] - AssertionError: expected: 'f *'
FAILED tests/features/text_editing_test.py::test_press_enter_beginning_of_file[fake] - AssertionError: expected: 'f *'
FAILED tests/features/undo_redo_test.py::test_undo_redo_mixed_newlines[fake] - AssertionError: expected: ' *'
FAILED tests/features/undo_redo_test.py::test_undo_redo_with_save[fake] - AssertionError: expected: ' *'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions