MCPcopy Index your code
hub / github.com/python/cpython / test_str_subclass

Method test_str_subclass

Lib/test/test_compare.py:385–405  ·  view source on GitHub ↗

Compare instances of str and a subclass.

(self)

Source from the content-addressed store, hash-verified

383 a1, b2, -1, cls_a.meth, cls_b.meth)
384
385 def test_str_subclass(self):
386 """Compare instances of str and a subclass."""
387 class StrSubclass(str):
388 pass
389
390 s1 = str("a")
391 s2 = str("b")
392 c1 = StrSubclass("a")
393 c2 = StrSubclass("b")
394 c3 = StrSubclass("b")
395
396 self.assert_total_order(s1, s1, 0)
397 self.assert_total_order(s1, s2, -1)
398 self.assert_total_order(c1, c1, 0)
399 self.assert_total_order(c1, c2, -1)
400 self.assert_total_order(c2, c3, 0)
401
402 self.assert_total_order(s1, c2, -1)
403 self.assert_total_order(s2, c3, 0)
404 self.assert_total_order(c1, s2, -1)
405 self.assert_total_order(c2, s2, 0)
406
407 def test_numbers(self):
408 """Compare number types."""

Callers

nothing calls this directly

Calls 3

assert_total_orderMethod · 0.95
strFunction · 0.85
StrSubclassClass · 0.70

Tested by

no test coverage detected