~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_gpg.py

  • Committer: Olaf Conradi
  • Date: 2006-03-28 23:30:02 UTC
  • mto: (1661.1.1 bzr.mbp.remember)
  • mto: This revision was merged to the branch mainline in revision 1663.
  • Revision ID: olaf@conradi.org-20060328233002-f6262df0e19c1963
Added testcases for using pull with --remember. Moved remember code to
beginning of cmd_pull. This remembers the location in case of a failure
during pull.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
import bzrlib.errors as errors
25
25
import bzrlib.gpg as gpg
26
 
from bzrlib.selftest import TestCase, TestCaseInTempDir
 
26
from bzrlib.tests import TestCase, TestCaseInTempDir
27
27
 
28
28
class FakeConfig(object):
29
29
 
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"
 
51
 
 
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')
 
61
 
 
62
            self.assertEqual(new_content, my_gpg.sign(content))
 
63
        else:
 
64
            my_gpg._command_line = lambda:['cat', '-']
 
65
            self.assertEqual(content, my_gpg.sign(content))
53
66
 
54
67
 
55
68
class TestDisabled(TestCase):