diff --git a/itsdangerous.py b/itsdangerous.py index 05362da..3a6fc8f 100644 --- a/itsdangerous.py +++ b/itsdangerous.py @@ -349,7 +349,9 @@ def get_signature(self, value): def sign(self, value): """Signs the given string.""" - return value + want_bytes(self.sep) + self.get_signature(value) + return want_bytes(value) + \ + want_bytes(self.sep) + \ + self.get_signature(value) def verify_signature(self, value, sig): """Verifies the signature for the given value.""" diff --git a/tests.py b/tests.py index 6fbef79..11abcd9 100755 --- a/tests.py +++ b/tests.py @@ -28,6 +28,16 @@ def test_want_bytes(self): self.assertEqual(want_bytes(u"foobar"), b"foobar") +class SignerTestCase(unittest.TestCase): + signer_class = idmod.Signer + def make_signer(self, *args, **kwargs): + return self.signer_class(*args, **kwargs) + + def test_sign(self): + s = self.make_signer('secret-key') + assert isinstance(s.sign('my string'), bytes) + + class SerializerTestCase(unittest.TestCase): serializer_class = idmod.Serializer