blob: 2e631062837ffa59fffec016279fe64e53502743 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import pytest
from spack.cmd import require_python_name, python_name, PythonNameError, \
require_cmd_name, cmd_name, CommandNameError
def test_require_python_name():
"""Python module names should not contain dashes---ensure that
require_python_name() raises the appropriate exception if one is
detected.
"""
require_python_name("okey_dokey")
with pytest.raises(PythonNameError):
require_python_name("okey-dokey")
require_python_name(python_name("okey-dokey"))
def test_require_cmd_name():
"""By convention, Spack command names should contain dashes rather than
underscores---ensure that require_cmd_name() raises the appropriate
exception if underscores are detected.
"""
require_cmd_name("okey-dokey")
with pytest.raises(CommandNameError):
require_cmd_name("okey_dokey")
require_cmd_name(cmd_name("okey_dokey"))
|