diff --git a/core/app.py b/core/app.py index 09926cbe..bec30f3c 100644 --- a/core/app.py +++ b/core/app.py @@ -21,8 +21,7 @@ from hscommon.path import Path from hscommon.conflict import smart_move, smart_copy from hscommon.gui.progress_window import ProgressWindow -from hscommon.util import (delete_if_empty, first, escape, nonone, format_time_decimal, allsame, - rem_file_ext) +from hscommon.util import delete_if_empty, first, escape, nonone, format_time_decimal, allsame from hscommon.trans import tr from hscommon.plat import ISWINDOWS from hscommon import desktop @@ -90,10 +89,7 @@ def format_dupe_count(c): return str(c) if c else '---' def cmp_value(dupe, attrname): - if attrname == 'name': - value = rem_file_ext(dupe.name) - else: - value = getattr(dupe, attrname, '') + value = getattr(dupe, attrname, '') return value.lower() if isinstance(value, str) else value def fix_surrogate_encoding(s, encoding='utf-8'): @@ -205,13 +201,11 @@ def _get_dupe_sort_key(self, dupe, get_group, key, delta): else: result = cmp_value(dupe, key) if delta: - refval = getattr(get_group().ref, key) + refval = cmp_value(get_group().ref, key) if key in self.result_table.DELTA_COLUMNS: result -= refval else: - # We use directly getattr() because cmp_value() does thing that we don't want to do - # when we want to determine whether two values are exactly the same. - same = getattr(dupe, key) == refval + same = cmp_value(dupe, key) == refval result = (same, result) return result diff --git a/core/gui/result_table.py b/core/gui/result_table.py index a9862f71..155db06f 100644 --- a/core/gui/result_table.py +++ b/core/gui/result_table.py @@ -42,7 +42,7 @@ def is_cell_delta(self, column_name): dupe_info = self.data ref_info = self._group.ref.get_display_info(group=self._group, delta=False) for key, value in dupe_info.items(): - if ref_info[key] != value: + if (key not in self._delta_columns) and (ref_info[key].lower() != value.lower()): self._delta_columns.add(key) return column_name in self._delta_columns diff --git a/core/tests/result_table_test.py b/core/tests/result_table_test.py index 9640a433..82b0636a 100644 --- a/core/tests/result_table_test.py +++ b/core/tests/result_table_test.py @@ -44,3 +44,13 @@ def test_delta_flags_delta_mode_on_non_delta_columns(): assert not app.rtable[3].is_cell_delta('name') # "ibabtu" == "ibabtu", flag off assert not app.rtable[4].is_cell_delta('name') + +def test_delta_flags_delta_mode_on_non_delta_columns_case_insensitive(): + # Comparison that occurs for non-numeric columns to check whether they're delta is case + # insensitive + app = app_with_results() + app.app.results.groups[1].ref.name = "ibAbtu" + app.app.results.groups[1].dupes[0].name = "IBaBTU" + app.rtable.delta_values = True + # "ibAbtu" == "IBaBTU", flag off + assert not app.rtable[4].is_cell_delta('name') diff --git a/core/tests/results_test.py b/core/tests/results_test.py index bade68c1..e6803564 100644 --- a/core/tests/results_test.py +++ b/core/tests/results_test.py @@ -230,6 +230,23 @@ def test_group_of_duplicate_after_removal(self): # also remove group ref assert self.results.get_group_of_duplicate(ref) is None + def test_dupe_list_sort_delta_values_nonnumeric(self): + # When sorting dupes in delta mode on a non-numeric column, our first sort criteria is if + # the string is the same as its ref. + g1r, g1d1, g1d2, g2r, g2d1 = self.objects + # "aaa" makes our dupe go first in alphabetical order, but since we have the same value as + # ref, we're going last. + g2r.name = g2d1.name = "aaa" + self.results.sort_dupes('name', delta=True) + eq_("aaa", self.results.dupes[2].name) + + def test_dupe_list_sort_delta_values_nonnumeric_case_insensitive(self): + # Non-numeric delta sorting comparison is case insensitive + g1r, g1d1, g1d2, g2r, g2d1 = self.objects + g2r.name = "AaA" + g2d1.name = "aAa" + self.results.sort_dupes('name', delta=True) + eq_("aAa", self.results.dupes[2].name) class TestCaseResultsWithSavedResults: def setup_method(self, method):