From 009973f7f4b650aa20109e67edae673faf4f25f4 Mon Sep 17 00:00:00 2001 From: nfnty Date: Tue, 24 Jan 2017 06:27:07 +0100 Subject: container.fsobject: Fix natural sort Fixes #749 --- tests/ranger/container/test_fsobject.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/ranger/container/test_fsobject.py b/tests/ranger/container/test_fsobject.py index 2c6a693f..d2c9a770 100644 --- a/tests/ranger/container/test_fsobject.py +++ b/tests/ranger/container/test_fsobject.py @@ -21,15 +21,34 @@ def create_filesystem_object(path): def test_basename_natural1(): """Test filenames without extensions.""" - fsos = [create_filesystem_object(path) - for path in ("hello", "hello1", "hello2")] + fsos = [ + create_filesystem_object(path) + for path in ( + "0", "1", "2", "3", + "10", "11", "12", "13", + "100", "101", "102", "103", + "110", "111", "112", "113", + "hello", + "hello1", "hello2", + "hello11", "hello12", + "hello100", "hello101", "hello111", "hello112", + ) + ] assert fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural")) assert fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural_lower")) def test_basename_natural2(): """Test filenames with extensions.""" - fsos = [create_filesystem_object(path) - for path in ("hello", "hello.txt", "hello1.txt", "hello2.txt")] + fsos = [ + create_filesystem_object(path) + for path in ( + "hello", "hello.txt", + "hello0.txt", "hello1.txt", "hello2.txt", "hello3.txt" + "hello10.txt", "hello11.txt", "hello12.txt", "hello13.txt" + "hello100.txt", "hello101.txt", "hello102.txt", "hello103.txt" + "hello110.txt", "hello111.txt", "hello112.txt", "hello113.txt" + ) + ] assert fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural")) assert fsos == sorted(fsos[::-1], key=operator.attrgetter("basename_natural_lower")) -- cgit 1.4.1-2-gfad0