Skip to content

fix: unique_hosts wraps set in redundant list() - #111

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/bobber-unique-hosts-wraps-set-in-redundant-list
Open

fix: unique_hosts wraps set in redundant list()#111
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/bobber-unique-hosts-wraps-set-in-redundant-list

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

This PR addresses the following issue in bobber/bobber.py: unique_hosts wraps set in redundant list().

Changes

  • bobber/bobber.py: unique_hosts wraps set in redundant list().

Details

--- a/bobber/bobber.py
+++ b/bobber/bobber.py
@@ -1,1 +1,1 @@
-    if len(host_list) != len(list(set(host_list))):
+    if len(host_list) != len(set(host_list)):

Tests

  • tests/test_bobber_unique_hosts.py
--- /dev/null
+++ b/tests/test_bobber_unique_hosts.py
@@ -0,0 +1,15 @@
+import unittest
+from argparse import ArgumentTypeError
+import bobber.bobber as bobber_module
+
+
+class TestUniqueHosts(unittest.TestCase):
+    def test_returns_original_when_unique(self):
+        hosts = 'host1,host2,host3'
+        self.assertEqual(bobber_module.unique_hosts(hosts), hosts)
+
+    def test_rejects_duplicates(self):
+        hosts = 'host1,host1,host2'
+        with self.assertRaises(ArgumentTypeError):
+            bobber_module.unique_hosts(hosts)

Contributor guidelines

Per this repo's CONTRIBUTING.md:

  • All commits are signed off (Signed-off-by trailer, DCO).

Signed-off-by: Andrew White <andrewh@cdw.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant