diff options
-rwxr-xr-x | tools/build_test_env.sh | 7 | ||||
-rw-r--r-- | tools/python_test_v4.py | 14 |
2 files changed, 11 insertions, 10 deletions
diff --git a/tools/build_test_env.sh b/tools/build_test_env.sh index 0b2fc34..ebfb80a 100755 --- a/tools/build_test_env.sh +++ b/tools/build_test_env.sh @@ -26,7 +26,7 @@ fatal() { error "$@"; exit 1; } try() { "$@" || fatal "'$@' failed"; } NOVENV= -PY_VER=2 +PY_VER=3 API_VER=4 while getopts :np:a: opt "$@"; do case $opt in @@ -41,7 +41,7 @@ done case $PY_VER in 2) VENV_CMD=virtualenv;; - 3) VENV_CMD=pyvenv;; + 3) VENV_CMD="python3 -m venv";; *) fatal "Wrong python version (2 or 3)";; esac @@ -53,7 +53,6 @@ esac for req in \ curl \ docker \ - "${VENV_CMD}" \ ; do command -v "${req}" >/dev/null 2>&1 || fatal "${req} is required" @@ -96,7 +95,7 @@ testcase() { if [ -z "$NOVENV" ]; then log "Creating Python virtualenv..." - try "$VENV_CMD" "$VENV" + try $VENV_CMD "$VENV" . "$VENV"/bin/activate || fatal "failed to activate Python virtual environment" log "Installing dependencies into virtualenv..." diff --git a/tools/python_test_v4.py b/tools/python_test_v4.py index 02496a4..3b54936 100644 --- a/tools/python_test_v4.py +++ b/tools/python_test_v4.py @@ -364,7 +364,7 @@ admin_project.files.create({'file_path': 'README', 'content': 'Initial content', 'commit_message': 'Initial commit'}) readme = admin_project.files.get(file_path='README', ref='master') -readme.content = base64.b64encode(b"Improved README") +readme.content = base64.b64encode(b"Improved README").decode() time.sleep(2) readme.save(branch="master", commit_message="new commit") readme.delete(commit_message="Removing README", branch="master") @@ -374,7 +374,9 @@ admin_project.files.create({'file_path': 'README.rst', 'content': 'Initial content', 'commit_message': 'New commit'}) readme = admin_project.files.get(file_path='README.rst', ref='master') -assert(readme.decode() == 'Initial content') +# The first decode() is the ProjectFile method, the second one is the bytes +# object method +assert(readme.decode().decode() == 'Initial content') data = { 'branch': 'master', @@ -425,7 +427,7 @@ assert(len(tree) != 0) assert(tree[0]['name'] == 'README.rst') blob_id = tree[0]['id'] blob = admin_project.repository_raw_blob(blob_id) -assert(blob == 'Initial content') +assert(blob.decode() == 'Initial content') archive1 = admin_project.repository_archive() archive2 = admin_project.repository_archive('master') assert(archive1 == archive2) @@ -579,7 +581,7 @@ assert(len(discussion.attributes['notes']) == 1) snippet.file_name = 'bar.py' snippet.save() snippet = admin_project.snippets.get(snippet.id) -assert(snippet.content() == 'initial content') +assert(snippet.content().decode() == 'initial content') assert(snippet.file_name == 'bar.py') size = len(admin_project.snippets.list()) snippet.delete() @@ -741,7 +743,7 @@ snippet.save() snippet = gl.snippets.get(snippet.id) assert(snippet.title == 'updated_title') content = snippet.content() -assert(content == 'import gitlab') +assert(content.decode() == 'import gitlab') assert(snippet.user_agent_detail()['user_agent']) @@ -775,7 +777,7 @@ for i in range(20, 40): except gitlab.GitlabCreateError as e: error_message = e.error_message break -assert 'Retry later' in error_message +assert 'Retry later' in error_message.decode() [current_project.delete() for current_project in projects] settings.throttle_authenticated_api_enabled = False settings.save() |