# Path: pygit2.py

# 
# Path: test/utils.py
# class NoRepoTestCase(unittest.TestCase):
# 
#     def setUp(self):
#         self._temp_dir = tempfile.mkdtemp()
#         self.repo = None
# 
#     def tearDown(self):
#         del self.repo
#         rmtree(self._temp_dir)
# 
#     def assertRaisesAssign(self, exc_class, instance, name, value):
#         try:
#             setattr(instance, name, value)
#         except:
#             self.assertEqual(exc_class, sys.exc_info()[0])
# 
#     def assertAll(self, func, entries):
#         return self.assertTrue(all(func(x) for x in entries))
# 
#     def assertAny(self, func, entries):
#         return self.assertTrue(any(func(x) for x in entries))
# 
#     def assertRaisesWithArg(self, exc_class, arg, func, *args, **kwargs):
#         try:
#             func(*args, **kwargs)
#         except exc_class as exc_value:
#             self.assertEqual((arg,), exc_value.args)
#         else:
#             self.fail('%s(%r) not raised' % (exc_class.__name__, arg))
# 
#     def assertEqualSignature(self, a, b):
#         # XXX Remove this once equality test is supported by Signature
#         self.assertEqual(a.name, b.name)
#         self.assertEqual(a.email, b.email)
#         self.assertEqual(a.time, b.time)
#         self.assertEqual(a.offset, b.offset)


import unittest
import time
from pygit2 import Signature
from .utils import NoRepoTestCase
# modification of the file, and distribution when not linked into
# a combined executable.)
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, write to
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.

from __future__ import absolute_import
from __future__ import unicode_literals



class SignatureTest(NoRepoTestCase):

    def test_default(self):
        signature = Signature(
            '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)

    def test_ascii(self):
        self.assertRaises(UnicodeEncodeError,

# Path: pygit2.py

# 
# Path: test/utils.py
# class NoRepoTestCase(unittest.TestCase):
# 
#     def setUp(self):
#         self._temp_dir = tempfile.mkdtemp()
#         self.repo = None
# 
#     def tearDown(self):
#         del self.repo
#         rmtree(self._temp_dir)
# 
#     def assertRaisesAssign(self, exc_class, instance, name, value):
#         try:
#             setattr(instance, name, value)
#         except:
#             self.assertEqual(exc_class, sys.exc_info()[0])
# 
#     def assertAll(self, func, entries):
#         return self.assertTrue(all(func(x) for x in entries))
# 
#     def assertAny(self, func, entries):
#         return self.assertTrue(any(func(x) for x in entries))
# 
#     def assertRaisesWithArg(self, exc_class, arg, func, *args, **kwargs):
#         try:
#             func(*args, **kwargs)
#         except exc_class as exc_value:
#             self.assertEqual((arg,), exc_value.args)
#         else:
#             self.fail('%s(%r) not raised' % (exc_class.__name__, arg))
# 
#     def assertEqualSignature(self, a, b):
#         # XXX Remove this once equality test is supported by Signature
#         self.assertEqual(a.name, b.name)
#         self.assertEqual(a.email, b.email)
#         self.assertEqual(a.time, b.time)
#         self.assertEqual(a.offset, b.offset)


# Path: test/test_signature.py
import unittest
import time
from pygit2 import Signature
from .utils import NoRepoTestCase

# modification of the file, and distribution when not linked into
# a combined executable.)
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, write to
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.

from __future__ import absolute_import
from __future__ import unicode_literals



class SignatureTest(NoRepoTestCase):

    def test_default(self):
        signature = Signature(
            '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)

    def test_ascii(self):
        self.assertRaises(UnicodeEncodeError,

                          Signature, 'Foo Ibáñez', 'foo@example.com')