示例#1
0
def test_clear_nonexistent_file(tmpdir):
    """ clear should not create a file """
    i = Injections("testinjection")
    new_file = os.path.join(tmpdir.strpath, "dontcreateme")
    i.clear(new_file)
    i.commit()
    assert not os.path.exists(new_file)
示例#2
0
def test_similar_injectionname(test_file, injections):
    injections.inject(test_file.strpath, TEST_INJECTION)
    injections.commit()
    SIMILAR_INJECTION = "This is a similar injection"
    i_similiar = Injections("testinjectionsagain")
    i_similiar.inject(test_file.strpath, SIMILAR_INJECTION)
    i_similiar.commit()
    assert test_file.read().count(SIMILAR_INJECTION) > 0,\
        "Similar injection was removed!"
    assert test_file.read().count(SIMILAR_INJECTION) == 1,\
        "Multiple injections were found!"
    injections.clear(test_file.strpath)
    injections.commit()
    assert test_file.read().find(TEST_INJECTION) == -1,\
        "Injection was not cleared properly!"
    assert test_file.read().find(SIMILAR_INJECTION) > 0,\
        "Similar Injection was incorrectly cleared!"
示例#3
0
def test_clear_nonexistent_file(tmpdir):
    """ clear should not create a file """
    i = Injections("testinjection")
    new_file = os.path.join(tmpdir.strpath, "dontcreateme")
    i.clear(new_file)
    i.commit()
    assert not os.path.exists(new_file)
示例#4
0
def test_similar_injectionname(test_file, injections):
    injections.inject(test_file.strpath, TEST_INJECTION)
    injections.commit()
    SIMILAR_INJECTION = "This is a similar injection"
    i_similiar = Injections("testinjectionsagain")
    i_similiar.inject(test_file.strpath, SIMILAR_INJECTION)
    i_similiar.commit()
    assert test_file.read().count(SIMILAR_INJECTION) > 0,\
        "Similar injection was removed!"
    assert test_file.read().count(SIMILAR_INJECTION) == 1,\
        "Multiple injections were found!"
    injections.clear(test_file.strpath)
    injections.commit()
    assert test_file.read().find(TEST_INJECTION) == -1,\
        "Injection was not cleared properly!"
    assert test_file.read().find(SIMILAR_INJECTION) > 0,\
        "Similar Injection was incorrectly cleared!"
示例#5
0
def test_unicode():
    """ Test the unicode functionality """
    i = Injections("\xf0\x9f\x86\x92", override="OVERRIDE")
    i.inject_content(TEST_CONTENT, "injectme")
示例#6
0
def injections():
    return Injections("testinjection", override="OVERRIDE")
示例#7
0
def test_unicode():
    """ Test the unicode functionality """
    i = Injections("\xf0\x9f\x86\x92", override="OVERRIDE")
    i.inject_content(TEST_CONTENT, "injectme")
示例#8
0
def injections():
    return Injections("testinjection")