diff options
author | initial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-21 21:11:06 +0000 |
---|---|---|
committer | initial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-21 21:11:06 +0000 |
commit | 01593319d061fa65811a30c0d37fff1755f9db62 (patch) | |
tree | fb1d9bd99b96eb239ea28f84f767ab21921c02d9 /tools/buildbot/pylibs/twisted/test/test_abstract.py | |
parent | 66aa1265b6ff166987ffc294b7796f827abd27bc (diff) | |
download | chromium_src-01593319d061fa65811a30c0d37fff1755f9db62.zip chromium_src-01593319d061fa65811a30c0d37fff1755f9db62.tar.gz chromium_src-01593319d061fa65811a30c0d37fff1755f9db62.tar.bz2 |
Add tools/buildbot to the repository.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3685 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/buildbot/pylibs/twisted/test/test_abstract.py')
-rw-r--r-- | tools/buildbot/pylibs/twisted/test/test_abstract.py | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/tools/buildbot/pylibs/twisted/test/test_abstract.py b/tools/buildbot/pylibs/twisted/test/test_abstract.py new file mode 100644 index 0000000..44b4646 --- /dev/null +++ b/tools/buildbot/pylibs/twisted/test/test_abstract.py @@ -0,0 +1,83 @@ +# Copyright (c) 2007 Twisted Matrix Laboratories. +# See LICENSE for details. + +""" +Tests for generic file descriptor based reactor support code. +""" + +from twisted.trial.unittest import TestCase + +from twisted.internet.abstract import isIPAddress + + +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')) |