def METHOD_NAME(repo):
    remote_master = repo.lookup_branch('origin/master', pygit2.GIT_BRANCH_REMOTE)
    master = repo.create_branch('master', repo[remote_master.target.hex])
    assert master.upstream is None
    master.upstream = remote_master
    assert master.upstream.branch_name == 'origin/master'
    def set_bad_upstream():
        master.upstream = 2.5
    with pytest.raises(TypeError): set_bad_upstream()
    master.upstream = None
    assert master.upstream is None