Exemplo n.º 1
0
    def test_int_options(self):

        options = Options()
        no_timeout = (None, None)
        self.assertEqual(timeout(options), no_timeout)
        options = Options(timeout=None)
        self.assertEqual(timeout(options), no_timeout)

        options = Options()
        self.assertEqual(timeout(options, (5,10)), (5,10))
        self.assertEqual(timeout(options, (5, None)), (5,None))

        options = Options(timeout=5)
        self.assertEqual(timeout(options), (5,5))

        options = Options(timeout=(5, 10))
        self.assertEqual(timeout(options), (5,10))

        options = Options(timeout=(5, None))
        self.assertEqual(timeout(options), (5,None))

        options = Options(timeout=(5, None))
        self.assertEqual(timeout(options), (5,None))
Exemplo n.º 2
0
    def test_str_options(self):

        options = Options(timeout=('5s', None))
        self.assertEqual(timeout(options), (5,None))

        options = Options(timeout=('5s', '10m'))
        expected = (5, 10*Timeout.MINUTE)
        self.assertEqual(timeout(options), expected)

        options = Options(timeout=('5m', '10m'))
        expected = (5*Timeout.MINUTE, 10*Timeout.MINUTE)
        self.assertEqual(timeout(options), expected)

        options = Options(timeout=('5h', '10h'))
        expected = (5*Timeout.HOUR, 10*Timeout.HOUR)
        self.assertEqual(timeout(options), expected)

        options = Options(timeout=('5m', '10m'))
        expected = (5*Timeout.MINUTE, 10*Timeout.MINUTE)
        self.assertEqual(timeout(options), expected)

        options = Options(timeout=('5d', '10d'))
        expected = (5*Timeout.DAY, 10*Timeout.DAY)
        self.assertEqual(timeout(options), expected)