summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_decimal.py14
-rw-r--r--Lib/test/test_epoll.py6
-rw-r--r--Lib/test/test_random.py2
-rw-r--r--Lib/test/test_socketserver.py2
-rw-r--r--Lib/test/test_timeout.py13
-rw-r--r--Lib/test/test_unicode.py18
-rw-r--r--Lib/test/test_xmlrpc.py10
7 files changed, 54 insertions, 11 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index a7726150b5..7c607f94ca 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -944,21 +944,27 @@ class DecimalArithmeticOperatorsTest(unittest.TestCase):
def thfunc1(cls):
d1 = Decimal(1)
d3 = Decimal(3)
- cls.assertEqual(d1/d3, Decimal('0.333333333'))
+ test1 = d1/d3
cls.synchro.wait()
- cls.assertEqual(d1/d3, Decimal('0.333333333'))
+ test2 = d1/d3
cls.finish1.set()
+
+ cls.assertEqual(test1, Decimal('0.333333333'))
+ cls.assertEqual(test2, Decimal('0.333333333'))
return
def thfunc2(cls):
d1 = Decimal(1)
d3 = Decimal(3)
- cls.assertEqual(d1/d3, Decimal('0.333333333'))
+ test1 = d1/d3
thiscontext = getcontext()
thiscontext.prec = 18
- cls.assertEqual(d1/d3, Decimal('0.333333333333333333'))
+ test2 = d1/d3
cls.synchro.set()
cls.finish2.set()
+
+ cls.assertEqual(test1, Decimal('0.333333333'))
+ cls.assertEqual(test2, Decimal('0.333333333333333333'))
return
diff --git a/Lib/test/test_epoll.py b/Lib/test/test_epoll.py
index 877a54ecc3..1e30d61c50 100644
--- a/Lib/test/test_epoll.py
+++ b/Lib/test/test_epoll.py
@@ -33,6 +33,12 @@ from test import test_support
if not hasattr(select, "epoll"):
raise test_support.TestSkipped("test works only on Linux 2.6")
+try:
+ select.epoll()
+except IOError as e:
+ if e.errno == errno.ENOSYS:
+ raise test_support.TestSkipped("kernel doesn't support epoll()")
+
class TestEPoll(unittest.TestCase):
def setUp(self):
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 073b0d0602..c02eb09267 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -412,6 +412,7 @@ class TestDistributions(unittest.TestCase):
g.random = x[:].pop; g.gammavariate(1.0, 1.0)
g.random = x[:].pop; g.gammavariate(200.0, 1.0)
g.random = x[:].pop; g.betavariate(3.0, 3.0)
+ g.random = x[:].pop; g.triangular(0.0, 1.0, 1.0/3.0)
def test_avg_std(self):
# Use integration to test distribution average and standard deviation.
@@ -421,6 +422,7 @@ class TestDistributions(unittest.TestCase):
x = [i/float(N) for i in range(1,N)]
for variate, args, mu, sigmasqrd in [
(g.uniform, (1.0,10.0), (10.0+1.0)/2, (10.0-1.0)**2/12),
+ (g.triangular, (0.0, 1.0, 1.0/3.0), 4.0/9.0, 7.0/9.0/18.0),
(g.expovariate, (1.5,), 1/1.5, 1/1.5**2),
(g.paretovariate, (5.0,), 5.0/(5.0-1),
5.0/((5.0-1)**2*(5.0-2))),
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
index 7fe746d2f0..0656176cad 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -70,6 +70,7 @@ class SocketServerTest(unittest.TestCase):
self.test_files = []
def tearDown(self):
+ signal_alarm(0) # Didn't deadlock.
reap_children()
for fn in self.test_files:
@@ -78,7 +79,6 @@ class SocketServerTest(unittest.TestCase):
except os.error:
pass
self.test_files[:] = []
- signal_alarm(0) # Didn't deadlock.
def pickaddr(self, proto):
if proto == socket.AF_INET:
diff --git a/Lib/test/test_timeout.py b/Lib/test/test_timeout.py
index 803ea9f407..5986afaed2 100644
--- a/Lib/test/test_timeout.py
+++ b/Lib/test/test_timeout.py
@@ -107,16 +107,21 @@ class TimeoutTestCase(unittest.TestCase):
self.sock.close()
def testConnectTimeout(self):
- # Test connect() timeout
- _timeout = 0.001
- self.sock.settimeout(_timeout)
-
# If we are too close to www.python.org, this test will fail.
# Pick a host that should be farther away.
if (socket.getfqdn().split('.')[-2:] == ['python', 'org'] or
socket.getfqdn().split('.')[-2:-1] == ['xs4all']):
self.addr_remote = ('tut.fi', 80)
+ # Lookup the IP address to avoid including the DNS lookup time
+ # with the connect time. This avoids failing the assertion that
+ # the timeout occurred fast enough.
+ self.addr_remote = (socket.gethostbyname(self.addr_remote[0]), 80)
+
+ # Test connect() timeout
+ _timeout = 0.001
+ self.sock.settimeout(_timeout)
+
_t1 = time.time()
self.failUnlessRaises(socket.error, self.sock.connect,
self.addr_remote)
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index eed84929cf..f7e7cb4264 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -973,12 +973,26 @@ class UnicodeTest(
print('def\n', file=out)
def test_ucs4(self):
- if sys.maxunicode == 0xFFFF:
- return
x = '\U00100000'
y = x.encode("raw-unicode-escape").decode("raw-unicode-escape")
self.assertEqual(x, y)
+ # FIXME
+ #y = r'\U00100000'
+ #x = y.encode("raw-unicode-escape").decode("raw-unicode-escape")
+ #self.assertEqual(x, y)
+ #y = r'\U00010000'
+ #x = y.encode("raw-unicode-escape").decode("raw-unicode-escape")
+ #self.assertEqual(x, y)
+
+ #try:
+ # '\U11111111'.decode("raw-unicode-escape")
+ #except UnicodeDecodeError as e:
+ # self.assertEqual(e.start, 0)
+ # self.assertEqual(e.end, 10)
+ #else:
+ # self.fail("Should have raised UnicodeDecodeError")
+
def test_conversion(self):
# Make sure __unicode__() works properly
class Foo0:
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 083653383f..77d45253c8 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -421,6 +421,16 @@ class SimpleServerTestCase(unittest.TestCase):
# protocol error; provide additional information in test output
self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
+ def test_dotted_attribute(self):
+ # Raises an AttributeError because private methods are not allowed.
+ self.assertRaises(AttributeError,
+ SimpleXMLRPCServer.resolve_dotted_attribute, str, '__add')
+
+ self.assert_(SimpleXMLRPCServer.resolve_dotted_attribute(str, 'title'))
+ # Get the test to run faster by sending a request with test_simple1.
+ # This avoids waiting for the socket timeout.
+ self.test_simple1()
+
# This is a contrived way to make a failure occur on the server side
# in order to test the _send_traceback_header flag on the server
class FailingMessageClass(mimetools.Message):