Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the python test runner and add a test for it
- Loading branch information
Showing
3 changed files
with
95 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
|
||
# -*- coding: utf-8 -*- | ||
"""QGIS Unit tests for the docker python test runner | ||
.. note:: 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 2 of the License, or | ||
(at your option) any later version. | ||
""" | ||
__author__ = 'Alessandro Pasotti' | ||
__date__ = '19.11.2018' | ||
__copyright__ = 'Copyright 2018, The QGIS Project' | ||
# This will get replaced with a git SHA1 when you do a git archive | ||
__revision__ = '$Format:%H$' | ||
|
||
import qgis # NOQA | ||
import sys | ||
|
||
from qgis.testing import unittest, start_app | ||
from console import console | ||
from qgis.core import Qgis | ||
from qgis.PyQt.QtCore import QCoreApplication | ||
|
||
start_app() | ||
|
||
|
||
class TestTestRunner(unittest.TestCase): | ||
|
||
def test_fails(self): | ||
self.assertTrue(False) | ||
|
||
def test_passes(self): | ||
self.assertTrue(Qgis.QGIS_VERSION_INT > 0) | ||
|
||
@unittest.skip('Skipped!') | ||
def test_skipped(self): | ||
self.assertTrue(False) | ||
|
||
|
||
def _make_runner(tests=[]): | ||
suite = unittest.TestSuite() | ||
for t in tests: | ||
suite.addTest(TestTestRunner(t)) | ||
runner = unittest.TextTestRunner(verbosity=2) | ||
return runner.run(suite) | ||
|
||
|
||
# Test functions to be called by the runner | ||
|
||
def run_all(): | ||
"""Default function that is called by the runner if nothing else is specified""" | ||
return _make_runner(['test_fails', 'test_skipped', 'test_passes']) | ||
|
||
|
||
def run_failing(): | ||
"""Run failing test only""" | ||
return _make_runner(['test_fails']) | ||
|
||
|
||
def run_passes(): | ||
"""Run passing test only""" | ||
return _make_runner(['test_passes']) | ||
|
||
|
||
def run_skipped(): | ||
"""Run skipped test only""" | ||
return _make_runner(['test_skipped']) | ||
|
||
|
||
def run_skipped_and_passing(): | ||
"""Run skipped and passing test only""" | ||
return _make_runner(['test_skipped', 'test_passes']) |