<s> from __future__ import absolute_import , division , print_function , with_statement <EOL> import os <EOL> import platform <EOL> import socket <EOL> import sys <EOL> import textwrap <EOL> from tornado . testing import bind_unused_port <EOL> if sys . version_info < ( <NUM_LIT:2> , <NUM_LIT:7> ) : <EOL> import unittest2 as unittest <EOL> else : <EOL> from tornado . testing import unittest <EOL> skipIfNonUnix = unittest . skipIf ( os . name != '<STR_LIT>' or sys . platform == '<STR_LIT>' , <EOL> "<STR_LIT>" ) <EOL> skipOnTravis = unittest . skipIf ( '<STR_LIT>' in os . environ , <EOL> '<STR_LIT>' ) <EOL> skipOnAppEngine = unittest . skipIf ( '<STR_LIT>' in os . environ , <EOL> '<STR_LIT>' ) <EOL> skipIfNoNetwork = unittest . skipIf ( '<STR_LIT>' in os . environ , <EOL> '<STR_LIT>' ) <EOL> skipIfNoIPv6 = unittest . skipIf ( not socket . has_ipv6 , '<STR_LIT>' ) <EOL> skipBefore33 = unittest . skipIf ( sys . version_info < ( <NUM_LIT:3> , <NUM_LIT:3> ) , '<STR_LIT>' ) <EOL> skipBefore35 = unittest . skipIf ( sys . version_info < ( <NUM_LIT:3> , <NUM_LIT:5> ) , '<STR_LIT>' ) <EOL> skipNotCPython = unittest . skipIf ( platform . python_implementation ( ) != '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def refusing_port ( ) : <EOL> """<STR_LIT>""" <EOL> server_socket , port = bind_unused_port ( ) <EOL> server_socket . setblocking ( <NUM_LIT:1> ) <EOL> client_socket = socket . socket ( ) <EOL> client_socket . connect ( ( "<STR_LIT:127.0.0.1>" , port ) ) <EOL> conn , client_addr = server_socket . accept ( ) <EOL> conn . close ( ) <EOL> server_socket . close ( ) <EOL> return ( client_socket . close , client_addr [ <NUM_LIT:1> ] ) <EOL> def exec_test ( caller_globals , caller_locals , s ) : <EOL> """<STR_LIT>""" <EOL> global_namespace = dict ( caller_globals , ** caller_locals ) <EOL> local_namespace = { } <EOL> exec ( textwrap . dedent ( s ) , global_namespace , local_namespace ) <EOL> return local_namespace </s>
