Skip to content

Commit 902588f

Browse files
committed
RachisWarning visibility test
1 parent 9fd63b7 commit 902588f

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

q2cli/tests/test_cli.py

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66
# The full license is in the file LICENSE, distributed with this software.
77
# ----------------------------------------------------------------------------
88

9+
import click
10+
import contextlib
11+
import errno
912
import os.path
13+
from pathlib import Path
14+
import shutil
15+
import subprocess
16+
import tempfile
1017
import unittest
11-
import contextlib
1218
import unittest.mock
13-
import tempfile
14-
import shutil
15-
import click
16-
import errno
1719

1820
from click.testing import CliRunner
1921
from qiime2.core.cache import get_cache
@@ -484,6 +486,36 @@ def test_get_citations(self):
484486
self.assertEqual(result.exit_code, 0)
485487
self.assertEqual(result.output, EXPECTED_CITATIONS)
486488

489+
def test_rachis_warning_is_always_visible(self):
490+
'''
491+
Tests that the `RachisWarning` warning type gets passed to the standard
492+
error stream even when --verbose is not set. Also ensures that such
493+
errors are still visible with --verbose, and not visible with --quiet.
494+
'''
495+
with tempfile.TemporaryDirectory() as tempdir:
496+
base_command = [
497+
'qiime', 'dummy-plugin', 'raises-rachis-warning', '--o-output',
498+
Path(tempdir) / 'output.qza'
499+
]
500+
501+
# no verbose, no quiet
502+
output = subprocess.run(
503+
base_command, capture_output=True, text=True
504+
)
505+
self.assertIn('This is an important warning', output.stderr)
506+
507+
# verbose
508+
output = subprocess.run(
509+
base_command + ['--verbose'], capture_output=True, text=True
510+
)
511+
self.assertIn('This is an important warning', output.stderr)
512+
513+
# quiet
514+
output = subprocess.run(
515+
base_command + ['--quiet'], capture_output=True, text=True
516+
)
517+
self.assertNotIn('This is an important warning', output.stderr)
518+
487519

488520
class TestMigrated(unittest.TestCase):
489521
def setUp(self):

0 commit comments

Comments
 (0)