def test_has_readme_with_contents(tmpdir): tmpdir.chdir() tmpdir.mkdir("hello_world") subprocess.call(["git", "init"], cwd="hello_world") subprocess.call(["git", "config", "user.email", '"*****@*****.**"'], cwd="hello_world") subprocess.call(["git", "config", "user.name", '"My Name"'], cwd="hello_world") q = GitProject("hello_world") assert q.has_file_starting_with("README") is False success = q.check_for_nonempty_file("README")[0] assert not success with open("hello_world/README", "w") as f: f.write("Saluton, Mundo!") assert q.has_file_starting_with("README") assert q.has_file_starting_with("README") == "README" success = q.check_for_nonempty_file("README")[0] assert success
def test_has_license_with_empty_file(tmpdir): tmpdir.chdir() tmpdir.mkdir("hello_world") subprocess.call(["git", "init"], cwd="hello_world") subprocess.call(["git", "config", "user.email", '"*****@*****.**"'], cwd="hello_world") subprocess.call(["git", "config", "user.name", '"My Name"'], cwd="hello_world") q = GitProject("hello_world") assert q.has_file_starting_with("LICENSE") is False success = q.check_for_nonempty_file("LICENSE")[0] assert not success # Empty LICENSES are worthless! with open("hello_world/LICENSE", "w") as f: f.close() assert "LICENSE" in os.listdir("hello_world") assert q.has_file_starting_with("LICENSE") is False success = q.check_for_nonempty_file("LICENSE")[0] assert not success