File: tests.py

package info (click to toggle)
python-stopit 1.1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 128 kB
  • sloc: python: 180; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 974 bytes parent folder | download | duplicates (3)
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
29
30
# -*- coding: utf-8 -*-
import doctest
import os
import unittest

from stopit import ThreadingTimeout, threading_timeoutable, SignalTimeout, signal_timeoutable

# We run twice the same doctest with two distinct sets of globs
# This one is for testing signals based timeout control
signaling_globs = {
    'Timeout': SignalTimeout,
    'timeoutable': signal_timeoutable
}

# And this one is for testing threading based timeout control
threading_globs = {
    'Timeout': ThreadingTimeout,
    'timeoutable': threading_timeoutable
}


def suite():  # Func for setuptools.setup(test_suite=xxx)
    test_suite = unittest.TestSuite()
    test_suite.addTest(doctest.DocFileSuite('README.rst', globs=signaling_globs))
    if os.name == 'posix':  # Other OS have no support for signal.SIGALRM
        test_suite.addTest(doctest.DocFileSuite('README.rst', globs=threading_globs))
    return test_suite

if __name__ == '__main__':
    unittest.TextTestRunner(verbosity=2).run(suite())