|
6 | 6 | # The full license is in the file LICENSE, distributed with this software. |
7 | 7 | # ---------------------------------------------------------------------------- |
8 | 8 |
|
| 9 | +import click |
| 10 | +import contextlib |
| 11 | +import errno |
9 | 12 | import os.path |
| 13 | +from pathlib import Path |
| 14 | +import shutil |
| 15 | +import subprocess |
| 16 | +import tempfile |
10 | 17 | import unittest |
11 | | -import contextlib |
12 | 18 | import unittest.mock |
13 | | -import tempfile |
14 | | -import shutil |
15 | | -import click |
16 | | -import errno |
17 | 19 |
|
18 | 20 | from click.testing import CliRunner |
19 | 21 | from qiime2.core.cache import get_cache |
@@ -484,6 +486,36 @@ def test_get_citations(self): |
484 | 486 | self.assertEqual(result.exit_code, 0) |
485 | 487 | self.assertEqual(result.output, EXPECTED_CITATIONS) |
486 | 488 |
|
| 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 | + |
487 | 519 |
|
488 | 520 | class TestMigrated(unittest.TestCase): |
489 | 521 | def setUp(self): |
|
0 commit comments