|
| 1 | + |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +"""QGIS Unit tests for the docker python test runner |
| 4 | +
|
| 5 | +.. note:: This program is free software; you can redistribute it and/or modify |
| 6 | +it under the terms of the GNU General Public License as published by |
| 7 | +the Free Software Foundation; either version 2 of the License, or |
| 8 | +(at your option) any later version. |
| 9 | +""" |
| 10 | +__author__ = 'Alessandro Pasotti' |
| 11 | +__date__ = '19.11.2018' |
| 12 | +__copyright__ = 'Copyright 2018, The QGIS Project' |
| 13 | +# This will get replaced with a git SHA1 when you do a git archive |
| 14 | +__revision__ = '$Format:%H$' |
| 15 | + |
| 16 | +import qgis # NOQA |
| 17 | +import sys |
| 18 | + |
| 19 | +from qgis.testing import unittest |
| 20 | +from console import console |
| 21 | +from qgis.core import Qgis |
| 22 | + |
| 23 | + |
| 24 | +class TestTestRunner(unittest.TestCase): |
| 25 | + |
| 26 | + def test_fails(self): |
| 27 | + self.assertTrue(False) |
| 28 | + |
| 29 | + def test_passes(self): |
| 30 | + self.assertTrue(Qgis.QGIS_VERSION_INT > 0) |
| 31 | + |
| 32 | + @unittest.skip('Skipped!') |
| 33 | + def test_skipped(self): |
| 34 | + self.assertTrue(False) |
| 35 | + |
| 36 | + |
| 37 | +def _make_runner(tests=[]): |
| 38 | + suite = unittest.TestSuite() |
| 39 | + for t in tests: |
| 40 | + suite.addTest(TestTestRunner(t)) |
| 41 | + runner = unittest.TextTestRunner(verbosity=2) |
| 42 | + return runner.run(suite) |
| 43 | + |
| 44 | + |
| 45 | +# Test functions to be called by the runner |
| 46 | + |
| 47 | +def run_all(): |
| 48 | + """Default function that is called by the runner if nothing else is specified""" |
| 49 | + return _make_runner(['test_fails', 'test_skipped', 'test_passes']) |
| 50 | + |
| 51 | + |
| 52 | +def run_failing(): |
| 53 | + """Run failing test only""" |
| 54 | + return _make_runner(['test_fails']) |
| 55 | + |
| 56 | + |
| 57 | +def run_passing(): |
| 58 | + """Run passing test only""" |
| 59 | + return _make_runner(['test_passes']) |
| 60 | + |
| 61 | + |
| 62 | +def run_skipped(): |
| 63 | + """Run skipped test only""" |
| 64 | + return _make_runner(['test_skipped']) |
| 65 | + |
| 66 | + |
| 67 | +def run_skipped_and_passing(): |
| 68 | + """Run skipped and passing test only""" |
| 69 | + return _make_runner(['test_skipped', 'test_passes']) |
0 commit comments