diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2018-05-19 00:18:59 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2018-06-24 14:21:52 -0700 |
commit | 175de19f2d473d8e82959d1abfe8ea25812d76c3 (patch) | |
tree | 0159b83d98b3d82e74bc7b4c340def27e9eedd58 | |
parent | f476e60c01de00fa361acf69259f32ec3f2165ba (diff) | |
download | spack-175de19f2d473d8e82959d1abfe8ea25812d76c3.tar.gz spack-175de19f2d473d8e82959d1abfe8ea25812d76c3.tar.bz2 spack-175de19f2d473d8e82959d1abfe8ea25812d76c3.tar.xz spack-175de19f2d473d8e82959d1abfe8ea25812d76c3.zip |
tests: test html output for `spack list`
- make list test use SpackCommand
- convert to pytest
- add a test for HTML output
-rw-r--r-- | lib/spack/spack/test/cmd/list.py | 99 |
1 files changed, 37 insertions, 62 deletions
diff --git a/lib/spack/spack/test/cmd/list.py b/lib/spack/spack/test/cmd/list.py index 72174c6b7b..dba6c12350 100644 --- a/lib/spack/spack/test/cmd/list.py +++ b/lib/spack/spack/test/cmd/list.py @@ -22,84 +22,59 @@ # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## -import argparse - import pytest -import spack.cmd.list - - -@pytest.fixture(scope='module') -def parser(): - """Returns the parser for the module command""" - prs = argparse.ArgumentParser() - spack.cmd.list.setup_parser(prs) - return prs - - -@pytest.fixture() -def pkg_names(): - pkg_names = [] - return pkg_names - -@pytest.fixture() -def mock_name_only(monkeypatch, pkg_names): +from spack.main import SpackCommand - def name_only(x): - pkg_names.extend(x) +list = SpackCommand('list') - monkeypatch.setattr(spack.cmd.list, 'name_only', name_only) - monkeypatch.setitem(spack.cmd.list.formatters, 'name_only', name_only) +def test_list(): + output = list() + assert 'cloverleaf3d' in output + assert 'hdf5' in output -@pytest.mark.usefixtures('mock_name_only') -class TestListCommand(object): - def test_list(self, parser, pkg_names): +def test_list_filter(): + output = list('py-*') + assert 'py-numpy' in output + assert 'perl-file-copy-recursive' not in output - args = parser.parse_args([]) - spack.cmd.list.list(parser, args) + output = list('py-') + assert 'py-numpy' in output + assert 'perl-file-copy-recursive' in output - assert pkg_names - assert 'cloverleaf3d' in pkg_names - assert 'hdf5' in pkg_names - def test_list_filter(self, parser, pkg_names): - args = parser.parse_args(['py-*']) - spack.cmd.list.list(parser, args) +@pytest.mark.maybeslow +def test_list_search_description(): + output = list('--search-description', 'xml') + assert 'expat' in output - assert pkg_names - assert 'py-numpy' in pkg_names - assert 'perl-file-copy-recursive' not in pkg_names - args = parser.parse_args(['py-']) - spack.cmd.list.list(parser, args) +def test_list_tags(): + output = list('--tags', 'proxy-app') + assert 'cloverleaf3d' in output + assert 'hdf5' not in output - assert pkg_names - assert 'py-numpy' in pkg_names - assert 'perl-file-copy-recursive' in pkg_names - @pytest.mark.maybeslow - def test_list_search_description(self, parser, pkg_names): - args = parser.parse_args(['--search-description', 'xml']) - spack.cmd.list.list(parser, args) +def test_list_format_name_only(): + output = list('--format', 'name_only') + assert 'cloverleaf3d' in output + assert 'hdf5' in output - assert pkg_names - assert 'expat' in pkg_names - def test_list_tags(self, parser, pkg_names): - args = parser.parse_args(['--tags', 'proxy-app']) - spack.cmd.list.list(parser, args) +@pytest.mark.maybeslow +def test_list_format_rst(): + output = list('--format', 'rst') + assert '.. _cloverleaf3d:' in output + assert '.. _hdf5:' in output - assert pkg_names - assert 'cloverleaf3d' in pkg_names - assert 'hdf5' not in pkg_names - @pytest.mark.maybeslow - def test_list_formatter(self, parser, pkg_names): - # TODO: Test the output of the commands - args = parser.parse_args(['--format', 'name_only']) - spack.cmd.list.list(parser, args) +@pytest.mark.maybeslow +def test_list_format_html(): + output = list('--format', 'html') + assert '<div class="section" id="cloverleaf3d">' in output + assert '<h1>cloverleaf3d' in output - args = parser.parse_args(['--format', 'rst']) - spack.cmd.list.list(parser, args) + assert '<div class="section" id="hdf5">' in output + assert '<h1>hdf5' in output |