Mercurial > public > mercurial-scm > python-hglib
comparison tests/test-config.py @ 143:4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
author | Brett Cannon <brett@python.org> |
---|---|
date | Mon, 09 Mar 2015 18:26:25 -0400 |
parents | 9ecb271600fc |
children | c1b966866ed7 |
comparison
equal
deleted
inserted
replaced
142:fe74d5599539 | 143:4359cabcb0cc |
---|---|
1 import os, common, hglib | 1 import os, common, hglib |
2 from hglib.util import b | |
2 | 3 |
3 class test_config(common.basetest): | 4 class test_config(common.basetest): |
4 def setUp(self): | 5 def setUp(self): |
5 common.basetest.setUp(self) | 6 common.basetest.setUp(self) |
6 f = open('.hg/hgrc', 'a') | 7 f = open('.hg/hgrc', 'a') |
9 self.client = hglib.open() | 10 self.client = hglib.open() |
10 | 11 |
11 def test_basic(self): | 12 def test_basic(self): |
12 config = self.client.config() | 13 config = self.client.config() |
13 | 14 |
14 self.assertTrue(('section', 'key', 'value') in self.client.config()) | 15 self.assertTrue( |
16 (b('section'), b('key'), b('value')) in self.client.config()) | |
15 | 17 |
16 self.assertTrue([('section', 'key', 'value')], | 18 self.assertTrue([(b('section'), b('key'), b('value'))], |
17 self.client.config('section')) | 19 self.client.config(b('section'))) |
18 self.assertTrue([('section', 'key', 'value')], | 20 self.assertTrue([(b('section'), b('key'), b('value'))], |
19 self.client.config(['section', 'foo'])) | 21 self.client.config([b('section'), b('foo')])) |
20 self.assertRaises(hglib.error.CommandError, | 22 self.assertRaises(hglib.error.CommandError, |
21 self.client.config, ['a.b', 'foo']) | 23 self.client.config, [b('a.b'), b('foo')]) |
22 | 24 |
23 def test_show_source(self): | 25 def test_show_source(self): |
24 config = self.client.config(showsource=True) | 26 config = self.client.config(showsource=True) |
25 | 27 |
26 self.assertTrue((os.path.abspath('.hg/hgrc') + ':2', | 28 self.assertTrue((os.path.abspath(b('.hg/hgrc')) + b(':2'), |
27 'section', 'key', 'value') in config) | 29 b('section'), b('key'), b('value')) in config) |
28 | 30 |
29 class test_config_arguments(common.basetest): | 31 class test_config_arguments(common.basetest): |
30 def test_basic(self): | 32 def test_basic(self): |
31 client = hglib.open(configs=['diff.unified=5', 'a.b=foo']) | 33 client = hglib.open(configs=[b('diff.unified=5'), b('a.b=foo')]) |
32 self.assertEqual(client.config('a'), [('a', 'b', 'foo')]) | 34 self.assertEqual(client.config(b('a')), [(b('a'), b('b'), b('foo'))]) |
33 self.assertEqual(client.config('diff'), [('diff', 'unified', '5')]) | 35 self.assertEqual(client.config(b('diff')), |
36 [(b('diff'), b('unified'), b('5'))]) |