47
47
def test_returns_output(self):
48
48
# This test needs a 'cat' command or similar to work.
49
49
my_gpg = gpg.GPGStrategy(FakeConfig())
50
my_gpg._command_line = lambda:["cat", "-"]
51
self.assertEqual("some content\nwith newlines\n",
52
my_gpg.sign("some content\nwith newlines\n"))
50
content = "some content\nwith newlines\n"
52
if sys.platform == 'win32':
53
# Windows doesn't come with cat, and we don't require it
54
# so lets try using python instead.
55
# But stupid windows and line-ending conversions.
56
# It is too much work to make sys.stdout be in binary mode.
57
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65443
58
my_gpg._command_line = lambda:[sys.executable, '-c',
59
'import sys; sys.stdout.write(sys.stdin.read())']
60
new_content = content.replace('\n', '\r\n')
62
self.assertEqual(new_content, my_gpg.sign(content))
64
my_gpg._command_line = lambda:['cat', '-']
65
self.assertEqual(content, my_gpg.sign(content))
55
68
class TestDisabled(TestCase):