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)