From 576c15a46890d7ef94f1de927c053e2796f7f1c7 Mon Sep 17 00:00:00 2001 From: Alex Goodwin Date: Wed, 8 Nov 2023 23:07:18 +1000 Subject: [PATCH] Drop unmatched square bracket in Allegiance str method --- PyRoute/Galaxy.py | 4 ++-- Tests/Hypothesis/testAllegiance.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/PyRoute/Galaxy.py b/PyRoute/Galaxy.py index e4e673ae7..5d23e0d5f 100644 --- a/PyRoute/Galaxy.py +++ b/PyRoute/Galaxy.py @@ -129,7 +129,7 @@ def set_wiki_name(name, code, base): names[1] = names[1].strip() if '' == names[0]: raise ValueError("First part of name string must not be an empty string itself") - if '' == names[1]: + if '' == names[1] and ',' in name: raise ValueError("Second part of name string must not be an empty string itself") if code.startswith('Na'): @@ -144,7 +144,7 @@ def set_wiki_name(name, code, base): return '[[{}]]'.format(name) def __str__(self): - return '{} ([{})'.format(self.name, self.code) + return '{} ({})'.format(self.name, self.code) def is_unclaimed(self): return AllyGen.is_unclaimed(self) diff --git a/Tests/Hypothesis/testAllegiance.py b/Tests/Hypothesis/testAllegiance.py index 8377f7772..f086c557b 100644 --- a/Tests/Hypothesis/testAllegiance.py +++ b/Tests/Hypothesis/testAllegiance.py @@ -173,6 +173,11 @@ def test_set_wiki_name(self, name, code, base): assume(wiki_name is not None) self.assertNotIn('[]', wiki_name, "Empty square brackets not allowed in wiki name") + def test_string_representation(self): + alg = Allegiance("Test", "Test Allegiance Plz Ignore") + + expected = 'Test Allegiance Plz Ignore (Test)' + self.assertEqual(expected, str(alg), "Unexpected string representation") if __name__ == '__main__': unittest.main()