diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-03-19 14:00:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-03-19 14:00:14 +0000 |
commit | df9615bac55ac6f1c3f516b66279ac0007175030 (patch) | |
tree | 84dd81d1c97835271cea7fbdd67c074742365e07 /gitlint/tests/test_display.py | |
parent | Initial commit. (diff) | |
download | gitlint-df9615bac55ac6f1c3f516b66279ac0007175030.tar.xz gitlint-df9615bac55ac6f1c3f516b66279ac0007175030.zip |
Adding upstream version 0.13.1.upstream/0.13.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gitlint/tests/test_display.py')
-rw-r--r-- | gitlint/tests/test_display.py | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/gitlint/tests/test_display.py b/gitlint/tests/test_display.py new file mode 100644 index 0000000..1c64b34 --- /dev/null +++ b/gitlint/tests/test_display.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- + +try: + # python 2.x + from StringIO import StringIO +except ImportError: + # python 3.x + from io import StringIO + + +try: + # python 2.x + from mock import patch +except ImportError: + # python 3.x + from unittest.mock import patch # pylint: disable=no-name-in-module, import-error + +from gitlint.display import Display +from gitlint.config import LintConfig +from gitlint.tests.base import BaseTestCase + + +class DisplayTests(BaseTestCase): + def test_v(self): + display = Display(LintConfig()) + display.config.verbosity = 2 + + with patch('gitlint.display.stderr', new=StringIO()) as stderr: + # Non exact outputting, should output both v and vv output + with patch('gitlint.display.stdout', new=StringIO()) as stdout: + display.v(u"tëst") + display.vv(u"tëst2") + # vvvv should be ignored regardless + display.vvv(u"tëst3.1") + display.vvv(u"tëst3.2", exact=True) + self.assertEqual(u"tëst\ntëst2\n", stdout.getvalue()) + + # exact outputting, should only output v + with patch('gitlint.display.stdout', new=StringIO()) as stdout: + display.v(u"tëst", exact=True) + display.vv(u"tëst2", exact=True) + # vvvv should be ignored regardless + display.vvv(u"tëst3.1") + display.vvv(u"tëst3.2", exact=True) + self.assertEqual(u"tëst2\n", stdout.getvalue()) + + # standard error should be empty throughtout all of this + self.assertEqual('', stderr.getvalue()) + + def test_e(self): + display = Display(LintConfig()) + display.config.verbosity = 2 + + with patch('gitlint.display.stdout', new=StringIO()) as stdout: + # Non exact outputting, should output both v and vv output + with patch('gitlint.display.stderr', new=StringIO()) as stderr: + display.e(u"tëst") + display.ee(u"tëst2") + # vvvv should be ignored regardless + display.eee(u"tëst3.1") + display.eee(u"tëst3.2", exact=True) + self.assertEqual(u"tëst\ntëst2\n", stderr.getvalue()) + + # exact outputting, should only output v + with patch('gitlint.display.stderr', new=StringIO()) as stderr: + display.e(u"tëst", exact=True) + display.ee(u"tëst2", exact=True) + # vvvv should be ignored regardless + display.eee(u"tëst3.1") + display.eee(u"tëst3.2", exact=True) + self.assertEqual(u"tëst2\n", stderr.getvalue()) + + # standard output should be empty throughtout all of this + self.assertEqual('', stdout.getvalue()) |