andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.63k stars 177 forks source link

TestEmptyEndToEnd and TestEndToEndList fail with python3.10 #226

Closed tibequadorian closed 2 years ago

tibequadorian commented 2 years ago

This is due to a change in argparse, where "optional arguments" was replaced by "options" but your tests still expect the old string.

Version info trash-cli 0.21.10.24 python 3.10.3

Error log

=================================== FAILURES ===================================
_________________________ TestEmptyEndToEnd.test_help __________________________

self = <tests.empty.test_empty_end_to_end.TestEmptyEndToEnd testMethod=test_help>

        def test_help(self):
            result = run_command.run_command(self.tmp_dir, "trash-empty",
                                             ['--help'])
>           self.assertEqual(["""\
    usage: trash-empty [-h] [--version] [--trash-dir TRASH_DIR] [--all-users] [-i]
                       [-f]
                       [days]

    Purge trashed files.

    positional arguments:
      days

    optional arguments:
      -h, --help            show this help message and exit
      --version             show program's version number and exit
      --trash-dir TRASH_DIR
                            specify the trash directory to use
      --all-users           empty all trashcan of all the users
      -i, --interactive     ask before emptying trash directories
      -f                    don't ask before emptying trash directories

    Report bugs to https://github.com/andreafrancia/trash-cli/issues
    """, '', 0],
                             [result.stdout,
                              result.stderr,
                              result.exit_code])
E                             AssertionError: Lists differ: ["usa[189 chars]ptional arguments:\n  -h, --help            sh[445 chars]', 0] != ["usa[189 chars]ptions:\n  -h, --help            show this hel[434 chars]', 0]
E                             
E                             First differing element 0:
E                             "usag[188 chars]ptional arguments:\n  -h, --help            sh[437 chars]es\n"
E                             "usag[188 chars]ptions:\n  -h, --help            show this hel[426 chars]es\n"
E                             
E                             Diff is 829 characters long. Set self.maxDiff to None to see it.

tests/empty/test_empty_end_to_end.py:18: AssertionError
__________________________ TestEndToEndList.test_help __________________________

self = <tests.list.test_end_to_end_list.TestEndToEndList testMethod=test_help>

        def test_help(self):
            result = run_command.run_command(self.tmp_dir, "trash-list", ['--help'])

>           self.assertEqual("""\
    usage: trash-list [-h] [--version] [--trash-dir TRASH_DIRS]

    List trashed files

    optional arguments:
      -h, --help            show this help message and exit
      --version             show program's version number and exit
      --trash-dir TRASH_DIRS
                            specify the trash directory to use

    Report bugs to https://github.com/andreafrancia/trash-cli/issues
    """, result.stdout)
E   AssertionError: "usag[82 chars]ptional arguments:\n  -h, --help            sh[245 chars]es\n" != "usag[82 chars]ptions:\n  -h, --help            show this hel[234 chars]es\n"
E     usage: trash-list [-h] [--version] [--trash-dir TRASH_DIRS]
E     
E     List trashed files
E     
E   - optional arguments:
E   + options:
E       -h, --help            show this help message and exit
E       --version             show program's version number and exit
E       --trash-dir TRASH_DIRS
E                             specify the trash directory to use
E     
E     Report bugs to https://github.com/andreafrancia/trash-cli/issues

tests/list/test_end_to_end_list.py:46: AssertionError
=========================== short test summary info ============================
FAILED tests/empty/test_empty_end_to_end.py::TestEmptyEndToEnd::test_help - A...
FAILED tests/list/test_end_to_end_list.py::TestEndToEndList::test_help - Asse...
======================== 2 failed, 283 passed in 2.98s =========================
andreafrancia commented 2 years ago

Thank for your contribution. These test should be fixed in a way that make them pass both with python 3.10 but also with python 3.9.

andreafrancia commented 2 years ago

Fixed in 48b36308ca63ba2533b5c88930fc449e7365cb2f