Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions tests/test_restrict_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Comment on lines -59 to +63
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function assert_connect.assert_socket_connect refactored with the following changes:

code = code_template.format(test_url.hostname, test_url.port, test_name, mark)
testdir.makepyfile(code)

Expand Down