Rev 6361: Inherit from TestCaseWithTransport as we need some disk support, add a in file:///home/vila/src/bzr/reviews/commit-uses-config-stacks/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Dec 14 09:57:24 UTC 2011
At file:///home/vila/src/bzr/reviews/commit-uses-config-stacks/
------------------------------------------------------------
revno: 6361
revision-id: v.ladeuil+lp at free.fr-20111214095723-nzswy7z45ns8nv6g
parent: v.ladeuil+lp at free.fr-20111214095627-6xa2r0mbl8g7pnlm
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: commit-uses-config-stacks
timestamp: Wed 2011-12-14 10:57:23 +0100
message:
Inherit from TestCaseWithTransport as we need some disk support, add a
setUp() and build a specific GlobalStore there.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_gpg.py'
--- a/bzrlib/tests/test_gpg.py 2011-12-09 12:05:47 +0000
+++ b/bzrlib/tests/test_gpg.py 2011-12-14 09:57:23 +0000
@@ -21,8 +21,10 @@
import sys
from bzrlib import (
+ config,
errors,
gpg,
+ tests,
trace,
ui,
)
@@ -31,7 +33,8 @@
features,
)
-class FakeConfig(object):
+
+class FakeConfig(config.GlobalStack):
def get(self, name):
if name == "gpg_signing_key":
@@ -44,36 +47,42 @@
return None
-class TestCommandLine(TestCase):
+class TestCommandLine(tests.TestCaseWithTransport):
+
+ def setUp(self):
+ super(TestCommandLine, self).setUp()
+ store = config.GlobalStore()
+ store._load_from_string('''[DEFAULT]
+gpg_signing_key=amy at example.com
+gpg_signing_command=false''')
+ store.save()
+ self.my_gpg = gpg.GPGStrategy(config.GlobalStack())
def test_signing_command_line(self):
- my_gpg = gpg.GPGStrategy(FakeConfig())
self.assertEqual(['false', '--clearsign', '-u', 'amy at example.com'],
- my_gpg._command_line())
+ self.my_gpg._command_line())
def test_checks_return_code(self):
# This test needs a unix like platform - one with 'false' to run.
# if you have one, please make this work :)
- my_gpg = gpg.GPGStrategy(FakeConfig())
- self.assertRaises(errors.SigningFailed, my_gpg.sign, 'content')
+ self.assertRaises(errors.SigningFailed, self.my_gpg.sign, 'content')
def assertProduces(self, content):
# This needs a 'cat' command or similar to work.
- my_gpg = gpg.GPGStrategy(FakeConfig())
if sys.platform == 'win32':
# Windows doesn't come with cat, and we don't require it
# so lets try using python instead.
# But stupid windows and line-ending conversions.
# It is too much work to make sys.stdout be in binary mode.
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65443
- my_gpg._command_line = lambda:[sys.executable, '-c',
+ self.my_gpg._command_line = lambda:[sys.executable, '-c',
'import sys; sys.stdout.write(sys.stdin.read())']
new_content = content.replace('\n', '\r\n')
- self.assertEqual(new_content, my_gpg.sign(content))
+ self.assertEqual(new_content, self.my_gpg.sign(content))
else:
- my_gpg._command_line = lambda:['cat', '-']
- self.assertEqual(content, my_gpg.sign(content))
+ self.my_gpg._command_line = lambda:['cat', '-']
+ self.assertEqual(content, self.my_gpg.sign(content))
def test_returns_output(self):
content = "some content\nwith newlines\n"
More information about the bazaar-commits
mailing list