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)
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!"