コード例 #1
0
def benchmark_fields():
    options, _ = parse_commandline([''])
    action = Action(cmd='f')
    context = Context.from_options(options, [])
    t = timeit.Timer(
        lambda: action.apply(context, 'foo bar waz was haz has hair'))
    print t.repeat(repeat=3, number=100000)
コード例 #2
0
ファイル: pawk_test.py プロジェクト: chirayuk/pawk
def benchmark_fields():
    options, _ = parse_commandline([''])
    action = Action(cmd='f')
    context = Context.from_options(options, [])
    t = timeit.Timer(lambda: action.apply(context, 'foo bar waz was haz has hair'))
    print t.repeat(repeat=3, number=100000)
コード例 #3
0
ファイル: pawk_test.py プロジェクト: chirayuk/pawk
def test_action_match_negate():
    action = Action(r'(\w+) \w+', negate=True)
    groups = action._match('test case')
    assert groups is None
    groups = action._match('test')
    assert groups == ()
コード例 #4
0
ファイル: pawk_test.py プロジェクト: chirayuk/pawk
def test_action_match():
    action = Action(r'(\w+) \w+')
    groups = action._match('test case')
    assert groups == ('test',)
コード例 #5
0
def test_action_match_negate():
    action = Action(r'(\w+) \w+', negate=True)
    groups = action._match('test case')
    assert groups is None
    groups = action._match('test')
    assert groups == ()
コード例 #6
0
def test_action_match():
    action = Action(r'(\w+) \w+')
    groups = action._match('test case')
    assert groups == ('test', )
コード例 #7
0
def test_action_parse():
    negate, pattern, cmd = Action()._parse_command(r'/(\w+)/ l')
    assert pattern == r'(\w+)'
    assert cmd == 'l'
    assert negate is False