Skip to contentSkip to conversation

selftests: tc-testing: preserve list order when removing duplicates

PATCH Applied [email protected] 2 participants 2 messages Feb 22 – Feb 24

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: tc-testing: preserve list order when removing duplicates

From: Naveen Anandhan <[email protected]>

Using set() removes duplicates but breaks ordering.
Test output should be deterministic, so replace with dict.fromkeys().

---
 tools/testing/selftests/tc-testing/tdc_helper.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/tc-testing/tdc_helper.py +2 -2
index 0440d252c4c5..e06f03c0fb5d 100644
@@ -16,9 +16,9 @@ def get_categorized_testlist(alltests, ucat):
 
 
 def get_unique_item(lst):
-    """ For a list, return a list of the unique items in the list. """
+    """Return unique items while preserving original order."""
     if len(lst) > 1:
-        return list(set(lst))
+        return list(dict.fromkeys(lst))
     else:
         return lst
 
Signature · 1 line
2.43.0
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Sun, 22 Feb 2026 15:25:36 +0530 you wrote:

From: Naveen Anandhan <[email protected]>

Using set() removes duplicates but breaks ordering.
Test output should be deterministic, so replace with dict.fromkeys().

[...]

Here is the summary with links:
- selftests: tc-testing: preserve list order when removing duplicates

    https://git.kernel.org/netdev/net-next/c/8ac768bb198c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html