summaryrefslogtreecommitdiff
path: root/build-aux/measurestack/test_misc.py
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-31 03:28:06 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-31 03:51:03 -0600
commit1a3f1e07ef06b8953b509352ff1c3872534f7583 (patch)
tree1614fc8f127a0955ab711f426632f7a5741dcaee /build-aux/measurestack/test_misc.py
parent6b50631a8d0aa1b64995ce562972068b9f214759 (diff)
measurestack: Fix pretty-printing of BaseName and QName
Diffstat (limited to 'build-aux/measurestack/test_misc.py')
-rw-r--r--build-aux/measurestack/test_misc.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/build-aux/measurestack/test_misc.py b/build-aux/measurestack/test_misc.py
index 5cdf629..cc496ea 100644
--- a/build-aux/measurestack/test_misc.py
+++ b/build-aux/measurestack/test_misc.py
@@ -5,8 +5,30 @@
# pylint: disable=unused-variable
+import pytest
+
from . import BaseName, QName
-def test_basename() -> None:
+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)