summaryrefslogtreecommitdiffstats
path: root/source3/stf/pythoncheck.py
blob: a13f1b3d5c4637a91aee627e54ac7661504c9fc5 (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
45
46
#! /usr/bin/python

# Comfychair test cases for Samba python extensions

# Copyright (C) 2003 by Tim Potter <tpot@samba.org>
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.

"""These tests are run by Samba's "make check"."""

import sys, comfychair

class ImportTest(comfychair.TestCase):
    """Check that all modules can be imported without error."""
    def runtest(self):
        python_modules = ['spoolss', 'lsa', 'samr', 'winbind', 'winreg',
                          'srvsvc', 'tdb', 'smb', 'tdbpack']
        for m in python_modules:
            try:
                __import__('samba.%s' % m)
            except ImportError, msg:
                self.log(str(msg))
                self.fail('error importing %s module' % m)

tests = [ImportTest]

if __name__ == '__main__':
    # Some magic to repend build directory to python path so we see the
    # objects we have built and not previously installed stuff.
    from distutils.util import get_platform
    from os import getcwd
    sys.path.insert(0, '%s/build/lib.%s-%s' %
                    (getcwd(), get_platform(), sys.version[0:3]))

    comfychair.main(tests)