Package x2go :: Package tests :: Module runalltests

[frames] | no frames]

# Source Code for Module x2go.tests.runalltests

     1  # -*- coding: utf-8 -*-
     2
     3  # Copyright (C) 2010-2016 by Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
     4  #
     5  # Python X2Go is free software; you can redistribute it and/or modify
     6  # it under the terms of the GNU Affero General Public License as published by
     7  # the Free Software Foundation; either version 3 of the License, or
     8  # (at your option) any later version.
     9  #
    10  # Python X2Go is distributed in the hope that it will be useful,
    11  # but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  # GNU Affero General Public License for more details.
    14  #
    15  # You should have received a copy of the GNU Affero General Public License
    16  # along with this program; if not, write to the
    17  # Free Software Foundation, Inc.,
    18  # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
    19
    20  """\
    21  This file is a default test runner as found in ZOPE/Plone products. It works
    22  fine for any kind of Python unit testing---as we do here for Python X2Go.
    23  """
    24
    25  import os
    26  import sys
    27
    28  base = os.path.join(os.path.split(os.path.split(os.getcwd())[0])[0])
    29
    30  # prepend the X2Go path (useful for building new packages)
    31  sys.path = [os.path.normpath(base)] + sys.path
    32
    33  import unittest
    34  TestRunner = unittest.TextTestRunner
    35  suite = unittest.TestSuite()
    36
    37  tests = os.listdir(os.curdir)
    38  tests = [n[:-3] for n in tests if n.startswith('test') and n.endswith('.py')]
    39
    40  for test in tests:
    41      m = __import__(test)
    42      if hasattr(m, 'test_suite'):
    43          suite.addTest(m.test_suite())
    44
    45  if __name__ == '__main__':
    46      TestRunner().run(suite)
    47