tests/test-dispatch.py
author Anton Shestakov <av6@dwimlabs.net>
Sun, 08 Apr 2018 20:53:07 +0800
changeset 37492 8d05938dd063
parent 36374 f0c94af0d70d
child 37924 32106c474086
permissions -rw-r--r--
hgweb: make followlines button absolutely positioned It used to have position: absolute only on annotate page, but it makes sense to have it everywhere, because the button shouldn't affect other elements at all. Especially since the button has a set height, which meant that for certain smaller fonts source lines were changing their height on hover. Note that the button doesn't set any of the usual properties that accompany absolute position (top, right, bottom or left). These properties would position the button without any account for source line padding. Instead, margins are used (the button already has all margins defined, they do the job).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28405
1d9d29d4813a tests: test-dispatch use print_function
timeless <timeless@mozdev.org>
parents: 28404
diff changeset
     1
from __future__ import absolute_import, print_function
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     2
import os
28404
06245740b408 tests: test-dispatch use absolute_import
timeless <timeless@mozdev.org>
parents: 14438
diff changeset
     3
from mercurial import (
06245740b408 tests: test-dispatch use absolute_import
timeless <timeless@mozdev.org>
parents: 14438
diff changeset
     4
    dispatch,
06245740b408 tests: test-dispatch use absolute_import
timeless <timeless@mozdev.org>
parents: 14438
diff changeset
     5
)
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     6
5178
18a9fbb5cd78 dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents: 5095
diff changeset
     7
def testdispatch(cmd):
18a9fbb5cd78 dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents: 5095
diff changeset
     8
    """Simple wrapper around dispatch.dispatch()
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     9
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    10
    Prints command and result value, but does not handle quoting.
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    11
    """
36374
f0c94af0d70d py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28405
diff changeset
    12
    print(b"running: %s" % (cmd,))
14438
08bfec2ef031 dispatch: wrap dispatch related information in a request class
Idan Kamara <idankk86@gmail.com>
parents: 9031
diff changeset
    13
    req = dispatch.request(cmd.split())
08bfec2ef031 dispatch: wrap dispatch related information in a request class
Idan Kamara <idankk86@gmail.com>
parents: 9031
diff changeset
    14
    result = dispatch.dispatch(req)
36374
f0c94af0d70d py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28405
diff changeset
    15
    print(b"result: %r" % (result,))
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    16
36374
f0c94af0d70d py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28405
diff changeset
    17
testdispatch(b"init test1")
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    18
os.chdir('test1')
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    19
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    20
# create file 'foo', add and commit
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 5178
diff changeset
    21
f = open('foo', 'wb')
36374
f0c94af0d70d py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28405
diff changeset
    22
f.write(b'foo\n')
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    23
f.close()
36374
f0c94af0d70d py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28405
diff changeset
    24
testdispatch(b"add foo")
f0c94af0d70d py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28405
diff changeset
    25
testdispatch(b"commit -m commit1 -d 2000-01-01 foo")
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    26
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    27
# append to file 'foo' and commit
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 5178
diff changeset
    28
f = open('foo', 'ab')
36374
f0c94af0d70d py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28405
diff changeset
    29
f.write(b'bar\n')
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    30
f.close()
36374
f0c94af0d70d py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28405
diff changeset
    31
testdispatch(b"commit -m commit2 -d 2000-01-02 foo")
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    32
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    33
# check 88803a69b24 (fancyopts modified command table)
36374
f0c94af0d70d py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28405
diff changeset
    34
testdispatch(b"log -r 0")
f0c94af0d70d py3: add b'' prefixes in test-dispatch.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28405
diff changeset
    35
testdispatch(b"log -r tip")