コード例 #1
0
ファイル: test_utils.py プロジェクト: giltis/scikit-xray
def test_small_verbosedict():
    expected_string = ("You tried to access the key 'b' "
                   "which does not exist.  "
                   "The extant keys are: ['a']")
    dd = core.verbosedict()
    dd['a'] = 1
    assert_equal(dd['a'], 1)
    try:
        dd['b']
    except KeyError as e:
        assert_equal(eval(six.text_type(e)), expected_string)
    else:
        # did not raise a KeyError
        assert(False)
コード例 #2
0
ファイル: test_utils.py プロジェクト: giltis/scikit-xray
def test_large_verbosedict():
    expected_sting = ("You tried to access the key 'a' "
                      "which does not exist.  There are 100 "
                      "extant keys, which is too many to show you")

    dd = core.verbosedict()
    for j in range(100):
        dd[j] = j
    # test success
    for j in range(100):
        assert_equal(dd[j], j)
    # test failure
    try:
        dd['a']
    except KeyError as e:
        assert_equal(eval(six.text_type(e)), expected_sting)
    else:
        # did not raise a KeyError
        assert(False)
コード例 #3
0
ファイル: scrape.py プロジェクト: ezzatoa/VTTools
    re.compile('^(?i)dict(ionary)?$'),
    "str":
    re.compile('^(?i)str(ing)?([-]?like)?'),
    'callable':
    re.compile('^(?i)(func(tion)?|callable)'),
}

sig_map = verbosedict({
    'object': 'basic:Variant',
    'array': 'basic:Variant',
    'matrix': 'basic:Variant',
    'list': 'basic:List',
    'tuple': 'basic:List',
    'seq': 'basic:List',
    'dtype': 'basic:String',
    'bool': 'basic:Boolean',
    'file': 'basic:File',
    'scalar': 'basic:Float',
    'float': 'basic:Float',
    'int': 'basic:Integer',
    'complex': 'basic:Variant',
    'dict': 'basic:Dictionary',
    'str': 'basic:String',
    'callable': 'basic:Variant'
})

precedence_list = ('list', 'tuple', 'seq', 'dict', 'array', 'matrix', 'dtype',
                   'str', 'scalar', 'complex', 'float', 'int', 'bool', 'file',
                   'callable', 'object')

#   RE Details:
#   WORKS: test_str5 = "(your, mother, was, a, hampster) array"
コード例 #4
0
ファイル: scrape.py プロジェクト: Nikea/VTTools
    "complex": re.compile("^(?i)complex$"),
    "dict": re.compile("^(?i)dict(ionary)?$"),
    "str": re.compile("^(?i)str(ing)?([-]?like)?"),
    "callable": re.compile("^(?i)(func(tion)?|callable)"),
}

sig_map = verbosedict(
    {
        "object": "basic:Variant",
        "array": "basic:Variant",
        "matrix": "basic:Variant",
        "list": "basic:List",
        "tuple": "basic:List",
        "seq": "basic:List",
        "dtype": "basic:String",
        "bool": "basic:Boolean",
        "file": "basic:File",
        "scalar": "basic:Float",
        "float": "basic:Float",
        "int": "basic:Integer",
        "complex": "basic:Variant",
        "dict": "basic:Dictionary",
        "str": "basic:String",
        "callable": "basic:Variant",
    }
)


precedence_list = (
    "list",
    "tuple",
    "seq",