summaryrefslogtreecommitdiff
path: root/setuptools/command/test.py
blob: 62be4919d357a4ef452b47df8c733790ea24b959 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from distutils.cmd import Command
import sys

class test(Command):

    """Command to run unit tests after installation"""

    description = "Run unit tests after installation"

    user_options = [
        ('test-module=','m','Module to run tests from'),
    ]

    def initialize_options(self):
        self.test_module = None

    def finalize_options(self):

        if self.test_module is None:
            self.test_module = self.distribution.test_module

        self.test_args = [self.test_module+'.test_suite']

        if self.verbose:
            self.test_args.insert(0,'--verbose')

    def run(self):

        # Install before testing
        self.run_command('install')

        if not self.dry_run:
            import unittest
            unittest.main(None, None, [unittest.__file__]+self.test_args)