<commit_before># -*- coding: utf-8 -*-
# Copyright (C) 2016 <NAME>
# Published under the MIT License

from nose.tools import *
from guardonce.pattern_compiler import *

class Context:
    pass

def test_name():
    pattern = 'name'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filename = 'Match.h'
    assert_equals(createGuard(ctx), 'Match_h')

def test_path():
    pattern = 'path'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filepath = 'src/Match.h'
    assert_equals(createGuard(ctx), 'src_Match_h')

def test_path_arg():
    pattern = 'path 1'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filepath = 'src/widgets/Match.h'
    assert_equals(createGuard(ctx), 'widgets_Match_h')

def test_path_big_arg():
    pattern = 'path 10'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filepath = 'src/widgets/Match.h'
    assert_equals(createGuard(ctx), 'src_widgets_Match_h')

@raises(ParserError)
def test_path_bad_arg():
    pattern = 'path lkj'
    createGuard = compile_pattern(pattern)

def test_upper():
    pattern = 'name | upper'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filename = 'Match.h'
    assert_equals(createGuard(ctx), 'MATCH_H')

def test_lower():
    pattern = 'name | lower'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filename = 'Match.h'
    assert_equals(createGuard(ctx), 'match_h')

def test_snake():
    pattern = 'name | snake'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filename = 'MatchFactory.h'
    assert_equals(createGuard(ctx), 'match_factory_h')
<commit_msg>Fix path tests on Windows<commit_after># -*- coding: utf-8 -*-
# Copyright (C) 2016 <NAME>
# Published under the MIT License

import os
from nose.tools import *
from guardonce.pattern_compiler import *

class Context:
    pass

def test_name():
    pattern = 'name'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filename = 'Match.h'
    assert_equals(createGuard(ctx), 'Match_h')

def test_path():
    pattern = 'path'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filepath = os.path.join('src','Match.h')
    assert_equals(createGuard(ctx), 'src_Match_h')

def test_path_arg():
    pattern = 'path 1'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filepath = os.path.join('src','widgets','Match.h')
    assert_equals(createGuard(ctx), 'widgets_Match_h')

def test_path_big_arg():
    pattern = 'path 10'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filepath = os.path.join('src','widgets','Match.h')
    assert_equals(createGuard(ctx), 'src_widgets_Match_h')

@raises(ParserError)
def test_path_bad_arg():
    pattern = 'path lkj'
    createGuard = compile_pattern(pattern)

def test_upper():
    pattern = 'name | upper'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filename = 'Match.h'
    assert_equals(createGuard(ctx), 'MATCH_H')

def test_lower():
    pattern = 'name | lower'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filename = 'Match.h'
    assert_equals(createGuard(ctx), 'match_h')

def test_snake():
    pattern = 'name | snake'
    createGuard = compile_pattern(pattern)
    ctx = Context()
    ctx.filename = 'MatchFactory.h'
    assert_equals(createGuard(ctx), 'match_factory_h')

{'fraction_non_alphanumeric': 0.1295215869311552, 'fraction_numerical': 0.004667444574095682, 'mean_word_length': 3.9126074498567336, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4768792', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1110, 'n_words': 242}