Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.test_socket Namespace Reference

Classes

class  SocketTCPTest
class  SocketUDPTest
class  ThreadableTest
class  ThreadedTCPSocketTest
class  ThreadedUDPSocketTest
class  SocketConnectedTest
class  SocketPairTest
class  GeneralModuleTests
 Begin Tests. More...
class  BasicTCPTest
class  BasicUDPTest
class  TCPCloserTest
class  BasicSocketPairTest
class  NonBlockingTCPTests
class  FileObjectClassTestCase
class  FileObjectInterruptedTestCase
class  UnbufferedFileObjectClassTestCase
class  LineBufferedFileObjectClassTestCase
class  SmallBufferedFileObjectClassTestCase
class  UnicodeReadFileObjectClassTestCase
class  UnicodeWriteFileObjectClassTestCase
class  UnicodeReadWriteFileObjectClassTestCase
class  NetworkConnectionTest
class  BasicTCPTest2
class  NetworkConnectionNoServer
class  NetworkConnectionAttributesTest
class  NetworkConnectionBehaviourTest
class  TCPTimeoutTest
class  UDPTimeoutTest
class  TestExceptions
class  TestLinuxAbstractNamespace
class  BufferIOTest
class  TIPCTest
class  TIPCThreadableTest
class  ContextManagersTest
class  CloexecConstantTest
class  NonblockConstantTest

Functions

def try_address
def linux_version
def isTipcAvailable
def test_main

Variables

 fcntl = False
 HOST = support.HOST
string MSG = 'Michael Gilfix was here\u1234\r\n'
tuple SUPPORTS_IPV6 = socket.has_ipv6andtry_address('::1', family=socket.AF_INET6)
 test unicode string and carriage return
 thread = None
 threading = None
int TIPC_STYPE = 2000
int TIPC_LOWER = 200
int TIPC_UPPER = 210

Function Documentation

Check if the TIPC module is loaded

The TIPC module is not loaded automatically on Ubuntu and probably
other Linux distros.

Definition at line 1854 of file test_socket.py.

01854 
01855 def isTipcAvailable():
01856     """Check if the TIPC module is loaded
01857 
01858     The TIPC module is not loaded automatically on Ubuntu and probably
01859     other Linux distros.
01860     """
01861     if not hasattr(socket, "AF_TIPC"):
01862         return False
01863     if not os.path.isfile("/proc/modules"):
01864         return False
01865     with open("/proc/modules") as f:
01866         for line in f:
01867             if line.startswith("tipc "):
01868                 return True
01869     if support.verbose:
01870         print("TIPC module is not loaded, please 'sudo modprobe tipc'")
01871     return False

Here is the caller graph for this function:

Definition at line 38 of file test_socket.py.

00038 
00039 def linux_version():
00040     try:
00041         # platform.release() is something like '2.6.33.7-desktop-2mnb'
00042         version_string = platform.release().split('-')[0]
00043         return tuple(map(int, version_string.split('.')))
00044     except ValueError:
00045         return 0, 0, 0

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2036 of file test_socket.py.

02036 
02037 def test_main():
02038     tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest,
02039              TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest, UDPTimeoutTest ]
02040 
02041     tests.extend([
02042         NonBlockingTCPTests,
02043         FileObjectClassTestCase,
02044         FileObjectInterruptedTestCase,
02045         UnbufferedFileObjectClassTestCase,
02046         LineBufferedFileObjectClassTestCase,
02047         SmallBufferedFileObjectClassTestCase,
02048         UnicodeReadFileObjectClassTestCase,
02049         UnicodeWriteFileObjectClassTestCase,
02050         UnicodeReadWriteFileObjectClassTestCase,
02051         NetworkConnectionNoServer,
02052         NetworkConnectionAttributesTest,
02053         NetworkConnectionBehaviourTest,
02054         ContextManagersTest,
02055         CloexecConstantTest,
02056         NonblockConstantTest
02057     ])
02058     if hasattr(socket, "socketpair"):
02059         tests.append(BasicSocketPairTest)
02060     if sys.platform == 'linux2':
02061         tests.append(TestLinuxAbstractNamespace)
02062     if isTipcAvailable():
02063         tests.append(TIPCTest)
02064         tests.append(TIPCThreadableTest)
02065 
02066     thread_info = support.threading_setup()
02067     support.run_unittest(*tests)
02068     support.threading_cleanup(*thread_info)

Here is the call graph for this function:

def test.test_socket.try_address (   host,
  port = 0,
  family = socket.AF_INET 
)
Try to bind a socket on the given host:port and return True
if that has been possible.

Definition at line 26 of file test_socket.py.

00026 
00027 def try_address(host, port=0, family=socket.AF_INET):
00028     """Try to bind a socket on the given host:port and return True
00029     if that has been possible."""
00030     try:
00031         sock = socket.socket(family, socket.SOCK_STREAM)
00032         sock.bind((host, port))
00033     except (socket.error, socket.gaierror):
00034         return False
00035     else:
00036         sock.close()
00037         return True


Variable Documentation

Definition at line 24 of file test_socket.py.

Definition at line 46 of file test_socket.py.

string test.test_socket.MSG = 'Michael Gilfix was here\u1234\r\n'

Definition at line 47 of file test_socket.py.

tuple test.test_socket.SUPPORTS_IPV6 = socket.has_ipv6andtry_address('::1', family=socket.AF_INET6)

test unicode string and carriage return

Definition at line 48 of file test_socket.py.

Definition at line 54 of file test_socket.py.

Definition at line 55 of file test_socket.py.

Definition at line 1851 of file test_socket.py.

Definition at line 1850 of file test_socket.py.

Definition at line 1852 of file test_socket.py.