def test_sort_func(self):
        tags = [lambda s: s("foo"), "artistsort", "albumsort", "~filename", "~format", "discnumber", "~#track"]

        for tag in tags:
            f = AudioFile.sort_by_func(tag)
            f(bar_1_1)
            f(bar_1_2)
            f(bar_2_1)
Example #2
0
    def test_sort_func(self):
        tags = [lambda s: s("foo"), "artistsort", "albumsort",
                "~filename", "~format", "discnumber", "~#track"]

        for tag in tags:
            f = AudioFile.sort_by_func(tag)
            f(bar_1_1)
            f(bar_1_2)
            f(bar_2_1)
 def test_invalid_fs_encoding(self):
     # issue 798
     a = AudioFile()
     if os.name != "nt":
         a["~filename"] = "/\xf6\xe4\xfc/\xf6\xe4\xfc.ogg" # latin 1 encoded
         a.sort_by_func("~filename")(a)
         a.sort_by_func("~basename")(a)
     else:
         # windows
         a["~filename"] = "/\xf6\xe4\xfc/\xf6\xe4\xfc.ogg".decode("latin-1")
         a.sort_by_func("~filename")(a)
         a.sort_by_func("~basename")(a)
         a.sort_by_func("~dirname")(a)
 def test_invalid_fs_encoding(self):
     # issue 798
     a = AudioFile()
     if os.name != "nt":
         a["~filename"] = "/\xf6\xe4\xfc/\xf6\xe4\xfc.ogg"  # latin 1 encoded
         a.sort_by_func("~filename")(a)
         a.sort_by_func("~basename")(a)
     else:
         # windows
         a["~filename"] = "/\xf6\xe4\xfc/\xf6\xe4\xfc.ogg".decode("latin-1")
         a.sort_by_func("~filename")(a)
         a.sort_by_func("~basename")(a)
         a.sort_by_func("~dirname")(a)
Example #5
0
    def test_sort_func_custom_numeric(self):
        func = AudioFile.sort_by_func("~#year")

        files = [AudioFile({"year": "nope"}), AudioFile({"date": "2038"})]
        assert sorted(files, key=func) == files
Example #6
0
    def test_sort_func_custom_numeric(self):
        func = AudioFile.sort_by_func("~#year")

        files = [AudioFile({"year": "nope"}), AudioFile({"date": "2038"})]
        assert sorted(files, key=func) == files