From 3a200957e8ff26a94c250cc4bb0626328d1858ac Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Wed, 11 Jan 2023 21:26:50 +0000 Subject: [PATCH] Add a naturel sorting test --- tests/openlp_core/common/test_i18n.py | 10 ++++++++++ tests/openlp_core/display/test_window.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/openlp_core/common/test_i18n.py b/tests/openlp_core/common/test_i18n.py index add0fc1f5..ab76cb115 100644 --- a/tests/openlp_core/common/test_i18n.py +++ b/tests/openlp_core/common/test_i18n.py @@ -141,6 +141,16 @@ def test_get_natural_key(): # THEN: We get a properly sorted list assert sorted_list == ['1st item', 'item 3b', 'item 10a'], 'Numbers should be sorted naturally' + # GIVEN: The language is still English (a language, which sorts digits before letters) + mocked_get_language.return_value = 'en' + unsorted_list = ['1 songname', '100 songname', '2 songname'] + + # WHEN: We sort the list and use get_natural_key() to generate the sorting keys + sorted_list = sorted(unsorted_list, key=get_natural_key) + + # THEN: We get a properly sorted list + assert sorted_list == ['1 songname', '2 songname', '100 songname'], 'Numbers should be sorted naturally' + def test_check_same_instance(): """ diff --git a/tests/openlp_core/display/test_window.py b/tests/openlp_core/display/test_window.py index 7cf7c74d9..d977c9cf4 100644 --- a/tests/openlp_core/display/test_window.py +++ b/tests/openlp_core/display/test_window.py @@ -462,7 +462,7 @@ def test_fix_font_bold_not_windows(mocked_is_win, display_window_env, mock_setti @patch('openlp.core.display.window.is_win') -def test_fix_font_foundry(mocked_is_win, display_window_env, mock_settings): +def test_fix_font_foundry(mocked_is_win, display_window_env, mock_settings, registry): """ Test that a font with a foundry name in it has the foundry removed """