tests/test-ui-config.py
author Gregory Szorc <gregory.szorc@gmail.com>
Tue, 28 Aug 2018 15:02:48 -0700
changeset 39411 aeb551a3bb8a
parent 37942 32bc3815efae
child 43076 2372284d9457
permissions -rw-r--r--
cborutil: implement sans I/O decoder The vendored CBOR package decodes by calling read(n) on an object. There are a number of disadvantages to this: * Uses blocking I/O. If sufficient data is not available, the decoder will hang until it is. * No support for partial reads. If the read(n) returns less data than requested, the decoder raises an error. * Requires the use of a file like object. If the original data is in say a buffer, we need to "cast" it to e.g. a BytesIO to appease the decoder. In addition, the vendored CBOR decoder doesn't provide flexibility that we desire. Specifically: * It buffers indefinite length bytestrings instead of streaming them. * It doesn't allow limiting the set of types that can be decoded. This property is useful when implementing a "hardened" decoder that is less susceptible to abusive input. * It doesn't provide sufficient "hook points" and introspection to institute checks around behavior. These are useful for implementing a "hardened" decoder. This all adds up to a reasonable set of justifications for writing our own decoder. So, this commit implements our own CBOR decoder. At the heart of the decoder is a function that decodes a single "item" from a buffer. This item can be a complete simple value or a special value, such as "start of array." Using this function, we can build a decoder that effectively iterates over the stream of decoded items and builds up higher-level values, such as arrays, maps, sets, and indefinite length bytestrings. And we can do this without performing I/O in the decoder itself. The core of the sans I/O decoder will probably not be used directly. Instead, it is expected that we'll build utility functions for invoking the decoder given specific input types. This will allow extreme flexibility in how data is delivered to the decoder. I'm pretty happy with the state of the decoder modulo the TODO items to track wanted features to help with a "hardened" decoder. The one thing I could be convinced to change is the handling of semantic tags. Since we only support a single semantic tag (sets), I thought it would be easier to handle them inline in decodeitem(). This is simpler now. But if we add support for other semantic tags, it will likely be easier to move semantic tag handling outside of decodeitem(). But, properly supporting semantic tags opens up a whole can of worms, as many semantic tags imply new types. I'm optimistic we won't need these in Mercurial. But who knows. I'm also pretty happy with the test coverage. Writing comprehensive tests for partial decoding did flush out a handful of bugs. One general improvement to testing would be fuzz testing for partial decoding. I may implement that later. I also anticipate switching the wire protocol code to this new decoder will flush out any lingering bugs. Differential Revision: https://phab.mercurial-scm.org/D4414
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
     1
from __future__ import absolute_import, print_function
28680
ae606bdedc3e py3: make test-ui-config use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25660
diff changeset
     2
from mercurial import (
ae606bdedc3e py3: make test-ui-config use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25660
diff changeset
     3
    dispatch,
ae606bdedc3e py3: make test-ui-config use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25660
diff changeset
     4
    error,
37937
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
     5
    pycompat,
28776
5508a277bab2 tests: alias ui as uimod in test-ui-config
Yuya Nishihara <yuya@tcha.org>
parents: 28681
diff changeset
     6
    ui as uimod,
28680
ae606bdedc3e py3: make test-ui-config use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 25660
diff changeset
     7
)
37937
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
     8
from mercurial.utils import (
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
     9
    stringutil,
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    10
)
2502
18cf95ad3666 Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    11
30559
d83ca854fa21 ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28776
diff changeset
    12
testui = uimod.ui.load()
34858
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
    13
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
    14
# disable the configuration registration warning
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
    15
#
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
    16
# the purpose of this test is to check the old behavior, not to validate the
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
    17
# behavior from registered item. so we silent warning related to unregisted
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
    18
# config.
37519
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    19
testui.setconfig(b'devel', b'warn-config-unknown', False, b'test')
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    20
testui.setconfig(b'devel', b'all-warnings', False, b'test')
34858
85a2db47ad50 configitems: adds a developer warning when accessing undeclared configuration
Boris Feld <boris.feld@octobus.net>
parents: 32449
diff changeset
    21
8137
7fd0616b3d80 ui: kill updateopts
Matt Mackall <mpm@selenic.com>
parents: 5178
diff changeset
    22
parsed = dispatch._parseconfig(testui, [
37519
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    23
    b'values.string=string value',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    24
    b'values.bool1=true',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    25
    b'values.bool2=false',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    26
    b'values.boolinvalid=foo',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    27
    b'values.int1=42',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    28
    b'values.int2=-42',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    29
    b'values.intinvalid=foo',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    30
    b'lists.list1=foo',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    31
    b'lists.list2=foo bar baz',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    32
    b'lists.list3=alice, bob',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    33
    b'lists.list4=foo bar baz alice, bob',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    34
    b'lists.list5=abc d"ef"g "hij def"',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    35
    b'lists.list6="hello world", "how are you?"',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    36
    b'lists.list7=Do"Not"Separate',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    37
    b'lists.list8="Do"Separate',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    38
    b'lists.list9="Do\\"NotSeparate"',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    39
    b'lists.list10=string "with extraneous" quotation mark"',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    40
    b'lists.list11=x, y',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    41
    b'lists.list12="x", "y"',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    42
    b'lists.list13=""" key = "x", "y" """',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    43
    b'lists.list14=,,,,     ',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    44
    b'lists.list15=" just with starting quotation',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    45
    b'lists.list16="longer quotation" with "no ending quotation',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    46
    b'lists.list17=this is \\" "not a quotation mark"',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    47
    b'lists.list18=\n \n\nding\ndong',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    48
    b'date.epoch=0 0',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    49
    b'date.birth=2005-04-19T00:00:00',
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
    50
    b'date.invalid=0'
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
    51
    ])
2502
18cf95ad3666 Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    52
37937
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    53
def pprint(obj):
37942
32bc3815efae stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents: 37937
diff changeset
    54
    return stringutil.pprint(obj).decode('ascii')
37937
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    55
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    56
print(pprint(testui.configitems(b'values')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    57
print(pprint(testui.configitems(b'lists')))
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
    58
print("---")
37937
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    59
print(pprint(testui.config(b'values', b'string')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    60
print(pprint(testui.config(b'values', b'bool1')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    61
print(pprint(testui.config(b'values', b'bool2')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    62
print(pprint(testui.config(b'values', b'unknown')))
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
    63
print("---")
2502
18cf95ad3666 Allow using default values with ui.configlist, too, and add a test for this.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    64
try:
37937
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    65
    print(pprint(testui.configbool(b'values', b'string')))
25660
328739ea70c3 global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents: 14171
diff changeset
    66
except error.ConfigError as inst:
37937
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    67
    print(pprint(pycompat.bytestr(inst)))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    68
print(pprint(testui.configbool(b'values', b'bool1')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    69
print(pprint(testui.configbool(b'values', b'bool2')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    70
print(pprint(testui.configbool(b'values', b'bool2', True)))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    71
print(pprint(testui.configbool(b'values', b'unknown')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    72
print(pprint(testui.configbool(b'values', b'unknown', True)))
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
    73
print("---")
37937
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    74
print(pprint(testui.configint(b'values', b'int1')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    75
print(pprint(testui.configint(b'values', b'int2')))
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
    76
print("---")
37937
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    77
print(pprint(testui.configlist(b'lists', b'list1')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    78
print(pprint(testui.configlist(b'lists', b'list2')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    79
print(pprint(testui.configlist(b'lists', b'list3')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    80
print(pprint(testui.configlist(b'lists', b'list4')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    81
print(pprint(testui.configlist(b'lists', b'list4', [b'foo'])))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    82
print(pprint(testui.configlist(b'lists', b'list5')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    83
print(pprint(testui.configlist(b'lists', b'list6')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    84
print(pprint(testui.configlist(b'lists', b'list7')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    85
print(pprint(testui.configlist(b'lists', b'list8')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    86
print(pprint(testui.configlist(b'lists', b'list9')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    87
print(pprint(testui.configlist(b'lists', b'list10')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    88
print(pprint(testui.configlist(b'lists', b'list11')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    89
print(pprint(testui.configlist(b'lists', b'list12')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    90
print(pprint(testui.configlist(b'lists', b'list13')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    91
print(pprint(testui.configlist(b'lists', b'list14')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    92
print(pprint(testui.configlist(b'lists', b'list15')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    93
print(pprint(testui.configlist(b'lists', b'list16')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    94
print(pprint(testui.configlist(b'lists', b'list17')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    95
print(pprint(testui.configlist(b'lists', b'list18')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    96
print(pprint(testui.configlist(b'lists', b'unknown')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    97
print(pprint(testui.configlist(b'lists', b'unknown', b'')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    98
print(pprint(testui.configlist(b'lists', b'unknown', b'foo')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
    99
print(pprint(testui.configlist(b'lists', b'unknown', [b'foo'])))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
   100
print(pprint(testui.configlist(b'lists', b'unknown', b'foo bar')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
   101
print(pprint(testui.configlist(b'lists', b'unknown', b'foo, bar')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
   102
print(pprint(testui.configlist(b'lists', b'unknown', [b'foo bar'])))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
   103
print(pprint(testui.configlist(b'lists', b'unknown', [b'foo', b'bar'])))
32449
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
   104
print("---")
37937
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
   105
print(pprint(testui.configdate(b'date', b'epoch')))
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
   106
print(pprint(testui.configdate(b'date', b'birth')))
4069
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
   107
37937
a2cfea193040 tests: port test-ui-config to Python 3
Augie Fackler <augie@google.com>
parents: 37519
diff changeset
   108
print(pprint(testui.config(b'values', b'String')))
4069
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
   109
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
   110
def function():
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
   111
    pass
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
   112
3fef134832d8 allow values that aren't strings in util.configparser
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3346
diff changeset
   113
# values that aren't strings should work
37519
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
   114
testui.setconfig(b'hook', b'commit', function)
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
   115
print(function == testui.config(b'hook', b'commit'))
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
   116
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
   117
# invalid values
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
   118
try:
37519
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
   119
    testui.configbool(b'values', b'boolinvalid')
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
   120
except error.ConfigError:
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
   121
    print('boolinvalid')
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
   122
try:
37519
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
   123
    testui.configint(b'values', b'intinvalid')
14171
fa2b596db182 ui: add configint function and tests
Sune Foldager <cryo@cyanite.org>
parents: 12865
diff changeset
   124
except error.ConfigError:
28681
eda8b28e3b1b py3: make test-ui-config use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28680
diff changeset
   125
    print('intinvalid')
32449
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
   126
try:
37519
3740d1abde44 py3: add b'' prefixes in tests/test-ui-config.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 34858
diff changeset
   127
    testui.configdate(b'date', b'invalid')
32449
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
   128
except error.ConfigError:
0ed730f3301c ui: fix ui.configdate for invalid dates
Boris Feld <boris.feld@octobus.net>
parents: 30559
diff changeset
   129
    print('dateinvalid')