diff options
Diffstat (limited to 'build-aux/measurestack/test_analyze.py')
-rw-r--r-- | build-aux/measurestack/test_analyze.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/build-aux/measurestack/test_analyze.py b/build-aux/measurestack/test_analyze.py new file mode 100644 index 0000000..ff1732d --- /dev/null +++ b/build-aux/measurestack/test_analyze.py @@ -0,0 +1,34 @@ +# build-aux/measurestack/test_analyze.py - Tests for analyze.py +# +# Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com> +# SPDX-License-Identifier: AGPL-3.0-or-later + +# pylint: disable=unused-variable + +import pytest + +from .analyze import BaseName, QName + + +def test_name_base() -> None: + assert QName("foo.c:bar.1").base() == BaseName("bar") + + +def test_name_pretty() -> None: + name = QName("foo.c:bar.1") + assert f"{name}" == "QName('foo.c:bar.1')" + assert f"{name.base()}" == "BaseName('bar')" + assert f"{[name]}" == "[QName('foo.c:bar.1')]" + assert f"{[name.base()]}" == "[BaseName('bar')]" + + +def test_name_eq() -> None: + name = QName("foo.c:bar.1") + with pytest.raises(AssertionError) as e: + if name == "foo": + pass + assert "comparing QName with str" in str(e) + with pytest.raises(AssertionError) as e: + if name.base() == "foo": + pass + assert "comparing BaseName with str" in str(e) |