signature: rename Signature._name/_email to Signature.raw_name/raw_email

This commit is contained in:
Brodie Rao 2013-08-19 13:38:57 -07:00
parent 6d87567e0f
commit aec44c9ca2
3 changed files with 26 additions and 12 deletions

View File

@ -232,7 +232,9 @@ objects::
<pygit2.Signature object at 0x7f75e9b1f5f8>
.. autoattribute:: pygit2.Signature.name
.. autoattribute:: pygit2.Signature.raw_name
.. autoattribute:: pygit2.Signature.email
.. autoattribute:: pygit2.Signature.raw_email
.. autoattribute:: pygit2.Signature.time
.. autoattribute:: pygit2.Signature.offset

View File

@ -107,19 +107,19 @@ Signature__encoding__get__(Signature *self)
}
PyDoc_STRVAR(Signature__name__doc__, "Name (bytes).");
PyDoc_STRVAR(Signature_raw_name__doc__, "Name (bytes).");
PyObject *
Signature__name__get__(Signature *self)
Signature_raw_name__get__(Signature *self)
{
return to_bytes(self->signature->name);
}
PyDoc_STRVAR(Signature__email__doc__, "Email (bytes).");
PyDoc_STRVAR(Signature_raw_email__doc__, "Email (bytes).");
PyObject *
Signature__email__get__(Signature *self)
Signature_raw_email__get__(Signature *self)
{
return to_bytes(self->signature->email);
}
@ -162,8 +162,8 @@ Signature_offset__get__(Signature *self)
PyGetSetDef Signature_getseters[] = {
GETTER(Signature, _encoding),
GETTER(Signature, _name),
GETTER(Signature, _email),
GETTER(Signature, raw_name),
GETTER(Signature, raw_email),
GETTER(Signature, name),
GETTER(Signature, email),
GETTER(Signature, time),

View File

@ -41,8 +41,12 @@ class SignatureTest(NoRepoTestCase):
'Foo', 'foo@example.com', 1322174594, 60)
encoding = signature._encoding
self.assertEqual(encoding, 'ascii')
self.assertEqual(signature.name, signature._name.decode(encoding))
self.assertEqual(signature.name.encode(encoding), signature._name)
self.assertEqual(signature.name, signature.raw_name.decode(encoding))
self.assertEqual(signature.name.encode(encoding), signature.raw_name)
self.assertEqual(signature.email,
signature.raw_email.decode(encoding))
self.assertEqual(signature.email.encode(encoding),
signature.raw_email)
def test_ascii(self):
self.assertRaises(UnicodeEncodeError,
@ -53,16 +57,24 @@ class SignatureTest(NoRepoTestCase):
signature = Signature(
'Foo Ibáñez', 'foo@example.com', encoding=encoding)
self.assertEqual(encoding, signature._encoding)
self.assertEqual(signature.name, signature._name.decode(encoding))
self.assertEqual(signature.name.encode(encoding), signature._name)
self.assertEqual(signature.name, signature.raw_name.decode(encoding))
self.assertEqual(signature.name.encode(encoding), signature.raw_name)
self.assertEqual(signature.email,
signature.raw_email.decode(encoding))
self.assertEqual(signature.email.encode(encoding),
signature.raw_email)
def test_now(self):
encoding = 'utf-8'
signature = Signature(
'Foo Ibáñez', 'foo@example.com', encoding=encoding)
self.assertEqual(encoding, signature._encoding)
self.assertEqual(signature.name, signature._name.decode(encoding))
self.assertEqual(signature.name.encode(encoding), signature._name)
self.assertEqual(signature.name, signature.raw_name.decode(encoding))
self.assertEqual(signature.name.encode(encoding), signature.raw_name)
self.assertEqual(signature.email,
signature.raw_email.decode(encoding))
self.assertEqual(signature.email.encode(encoding),
signature.raw_email)
self.assertTrue(abs(signature.time - time.time()) < 5)