From 11413764000228b4db1d1b1318f25a9ed7541480 Mon Sep 17 00:00:00 2001 From: Sourcery AI Date: Sun, 21 Mar 2021 12:04:11 +0000 Subject: [PATCH] 'Refactored by Sourcery' --- tests/test_restrict_hosts.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_restrict_hosts.py b/tests/test_restrict_hosts.py index 92e5936..76c6bf2 100644 --- a/tests/test_restrict_hosts.py +++ b/tests/test_restrict_hosts.py @@ -56,10 +56,11 @@ def assert_socket_connect(should_pass, **kwargs): code_template = kwargs.get('code_template', connect_code_template) mark_arg = kwargs.get('mark_arg', None) - if mark_arg and isinstance(mark_arg, str): - mark = '@pytest.mark.allow_hosts("{0}")'.format(mark_arg) - elif mark_arg and isinstance(mark_arg, list): - mark = '@pytest.mark.allow_hosts(["{0}"])'.format('","'.join(mark_arg)) + if mark_arg: + if isinstance(mark_arg, str): + mark = '@pytest.mark.allow_hosts("{0}")'.format(mark_arg) + elif isinstance(mark_arg, list): + mark = '@pytest.mark.allow_hosts(["{0}"])'.format('","'.join(mark_arg)) code = code_template.format(test_url.hostname, test_url.port, test_name, mark) testdir.makepyfile(code)