Mercurial > public > mercurial-scm > python-hglib
annotate tests/test-config.py @ 145:f3c430afa598
hglib: abstract out use of cStringIO.StringIO (issue4520)
The cStringIO module does not exist in Python 3, but io.BytesIO does.
This change prepares for the use of io.BytesIO when available by
replacing all uses of cStringIO.StringIO with an object named BytesIO.
author | Brett Cannon <brett@python.org> |
---|---|
date | Fri, 13 Mar 2015 11:31:54 -0400 |
parents | 4359cabcb0cc |
children | c1b966866ed7 |
rev | line source |
---|---|
21 | 1 import os, common, hglib |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
2 from hglib.util import b |
21 | 3 |
4 class test_config(common.basetest): | |
5 def setUp(self): | |
6 common.basetest.setUp(self) | |
118
e738d6fe5f3f
tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents:
21
diff
changeset
|
7 f = open('.hg/hgrc', 'a') |
e738d6fe5f3f
tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents:
21
diff
changeset
|
8 f.write('[section]\nkey=value\n') |
e738d6fe5f3f
tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents:
21
diff
changeset
|
9 f.close() |
21 | 10 self.client = hglib.open() |
11 | |
12 def test_basic(self): | |
13 config = self.client.config() | |
14 | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
15 self.assertTrue( |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
16 (b('section'), b('key'), b('value')) in self.client.config()) |
21 | 17 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
18 self.assertTrue([(b('section'), b('key'), b('value'))], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
19 self.client.config(b('section'))) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
20 self.assertTrue([(b('section'), b('key'), b('value'))], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
21 self.client.config([b('section'), b('foo')])) |
21 | 22 self.assertRaises(hglib.error.CommandError, |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
23 self.client.config, [b('a.b'), b('foo')]) |
21 | 24 |
25 def test_show_source(self): | |
26 config = self.client.config(showsource=True) | |
27 | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
28 self.assertTrue((os.path.abspath(b('.hg/hgrc')) + b(':2'), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
29 b('section'), b('key'), b('value')) in config) |
132
9ecb271600fc
client: fix passing multiple config settings
Julien Cristau <julien.cristau@logilab.fr>
parents:
118
diff
changeset
|
30 |
9ecb271600fc
client: fix passing multiple config settings
Julien Cristau <julien.cristau@logilab.fr>
parents:
118
diff
changeset
|
31 class test_config_arguments(common.basetest): |
9ecb271600fc
client: fix passing multiple config settings
Julien Cristau <julien.cristau@logilab.fr>
parents:
118
diff
changeset
|
32 def test_basic(self): |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
33 client = hglib.open(configs=[b('diff.unified=5'), b('a.b=foo')]) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
34 self.assertEqual(client.config(b('a')), [(b('a'), b('b'), b('foo'))]) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
35 self.assertEqual(client.config(b('diff')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
132
diff
changeset
|
36 [(b('diff'), b('unified'), b('5'))]) |