File: test_pool_01.py

package info (click to toggle)
python-socketpool 0.5.3-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: python: 629; makefile: 4
file content (28 lines) | stat: -rw-r--r-- 604 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# -*- coding: utf-8 -
#
# This file is part of socketpool.
# See the NOTICE for more information.

import unittest

from socketpool import ConnectionPool, Connector
from socketpool.pool import MaxTriesError

class MessyConnector(Connector):

    def __init__(self, **options):
        pass

    def is_connected(self):
        return False

    def invalidate(self):
        pass


class PoolTestCase(unittest.TestCase):

    def test_size_on_isconnected_failure(self):
        pool = ConnectionPool(MessyConnector)
        self.assert_(pool.size == 0)
        self.assertRaises(MaxTriesError, pool.get)