Skip to content

Commit

Permalink
Merge pull request #1656 from reaperhulk/nameattribute-repr
Browse files Browse the repository at this point in the history
add repr for x509.NameAttribute
  • Loading branch information
dstufft committed Feb 13, 2015
2 parents a9c1317 + a498be8 commit cd9bdcd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cryptography/x509.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ def __eq__(self, other):
def __ne__(self, other):
return not self == other

def __repr__(self):
return "<NameAttribute(oid={oid}, value={value!r})>".format(
oid=self.oid,
value=self.value
)


class ObjectIdentifier(object):
def __init__(self, dotted_string):
Expand Down
7 changes: 7 additions & 0 deletions tests/test_x509.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@ def test_ne(self):
x509.ObjectIdentifier('oid'), 'value'
) != object()

def test_repr(self):
na = x509.NameAttribute(x509.ObjectIdentifier('2.5.4.3'), 'value')
assert repr(na) == (
"<NameAttribute(oid=<ObjectIdentifier(oid=2.5.4.3, name=commonName"
")>, value='value')>"
)


class TestObjectIdentifier(object):
def test_eq(self):
Expand Down

0 comments on commit cd9bdcd

Please sign in to comment.