def test_nameToLabel(self): """ Test the various kinds of inputs L{nameToLabel} supports. """ nameData = [ ('f', 'F'), ('fo', 'Fo'), ('foo', 'Foo'), ('fooBar', 'Foo Bar'), ('fooBarBaz', 'Foo Bar Baz'), ] for inp, out in nameData: got = util.nameToLabel(inp) self.assertEqual( got, out, "nameToLabel(%r) == %r != %r" % (inp, got, out))
def inspect(self): """ Return a multi-line, human-readable representation of this DN. @rtype: C{str} """ l = [] lablen = 0 def uniqueValues(mapping): return set(mapping.values()) for k in sorted(uniqueValues(_x509names)): label = util.nameToLabel(k) lablen = max(len(label), lablen) v = getattr(self, k, None) if v is not None: l.append((label, nativeString(v))) lablen += 2 for n, (label, attr) in enumerate(l): l[n] = (label.rjust(lablen)+': '+ attr) return '\n'.join(l)