annotate tests/test-config.py @ 180:ff6efc1ab9e4

protocol: allow hglib user to get call backs for prompts, output and errors setcbout(cbout), setcberr(cberr) and setcbprompt(cbprompt) are used to set the call back function used by the hgclient class. cb stands for call back. cbout is a function that will be called with the stdout data of the command as it runs. cbout is called with output as it is made available, which can be as partial lines or multiple lines. cberr is a function that will be called with the stderr data of the command as it runs. cberr is called with output as it is made available, which can be as partial lines or multiple lines. Command that make remote connects can prompt for username and password for HTTP/HTTPS connections. cbprompt is called when hgclient need a response to a prompt from the server. It receives the max number of bytes to return and the contents of stdout received so far. The last text sent to either cbout or cberr will contain the prompt text itself.
author Barry A. Scott <barry@barrys-emacs.org>
date Fri, 28 Oct 2016 11:33:20 +0100
parents c1b966866ed7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
148
c1b966866ed7 hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents: 143
diff changeset
1 from tests import common
c1b966866ed7 hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents: 143
diff changeset
2 import os, hglib
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 132
diff changeset
3 from hglib.util import b
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 class test_config(common.basetest):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 def setUp(self):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7 common.basetest.setUp(self)
118
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 21
diff changeset
8 f = open('.hg/hgrc', 'a')
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 21
diff changeset
9 f.write('[section]\nkey=value\n')
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 21
diff changeset
10 f.close()
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11 self.client = hglib.open()
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13 def test_basic(self):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 config = self.client.config()
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 132
diff changeset
16 self.assertTrue(
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 132
diff changeset
17 (b('section'), b('key'), b('value')) in self.client.config())
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 132
diff changeset
19 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
20 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
21 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
22 self.client.config([b('section'), b('foo')]))
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23 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
24 self.client.config, [b('a.b'), b('foo')])
21
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26 def test_show_source(self):
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27 config = self.client.config(showsource=True)
ffef7df076e8 client: rewrite config()
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
28
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 132
diff changeset
29 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
30 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
31
9ecb271600fc client: fix passing multiple config settings
Julien Cristau <julien.cristau@logilab.fr>
parents: 118
diff changeset
32 class test_config_arguments(common.basetest):
9ecb271600fc client: fix passing multiple config settings
Julien Cristau <julien.cristau@logilab.fr>
parents: 118
diff changeset
33 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
34 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
35 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
36 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
37 [(b('diff'), b('unified'), b('5'))])