Skip to content

Commit 0e89af2

Browse files
committed
update test
1 parent ea31579 commit 0e89af2

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

.generator/Dockerfile

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,11 @@ RUN for PYTHON_VERSION in 3.9.23 3.10.18 3.11.13 3.12.11 3.13.5; do \
5050
rm -rf Python-${PYTHON_VERSION}* \
5151
; done
5252

53-
ENV PYTHON_PIP_VERSION 25.1.1
54-
RUN wget --no-check-certificate -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
55-
&& python3.10 /tmp/get-pip.py "pip==$PYTHON_PIP_VERSION" \
56-
57-
# we use "--force-reinstall" for the case where the version of pip we're trying to install is the same as the version bundled with Python
58-
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
59-
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
60-
&& pip3 install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \
61-
62-
# then we use "pip list" to ensure we don't have more than one pip version installed
63-
# https://github.com/docker-library/python/pull/100
64-
&& [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ]
53+
RUN wget --no-check-certificate -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py'
6554

6655
# Ensure Pip for all python3 versions
6756
RUN python3.9 /tmp/get-pip.py
57+
RUN python3.10 /tmp/get-pip.py
6858
RUN python3.11 /tmp/get-pip.py
6959
RUN python3.12 /tmp/get-pip.py
7060
RUN python3.13 /tmp/get-pip.py

.generator/cli.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import subprocess
1919
import sys
2020
import subprocess
21+
from typing import List
2122

2223
logger = logging.getLogger()
2324

@@ -113,9 +114,21 @@ def handle_generate():
113114
logger.info("'generate' command executed.")
114115

115116

117+
def _run_nox_sessions(sessions:List[str]):
118+
"""Calls nox with the specified sessions.
119+
120+
Args:
121+
path (List[str]): The list of nox sessions to run.
122+
"""
123+
for nox_session in sessions:
124+
command = ["nox", "-s", nox_session]
125+
result = subprocess.run(command, capture_output=True, text=True, check=True)
126+
logger.info(result)
127+
128+
116129
def handle_build():
117130
"""The main coordinator for validating client library generation."""
118-
sesssions = [
131+
sessions = [
119132
"unit-3.9",
120133
"unit-3.10",
121134
"unit-3.11",
@@ -128,10 +141,8 @@ def handle_build():
128141
"mypy",
129142
"check_lower_bounds",
130143
]
131-
for nox_session in sesssions:
132-
command = ["nox", "-s", nox_session]
133-
result = subprocess.run(command, capture_output=True, text=True, check=True)
134-
logger.info(result)
144+
_run_nox_sessions(sessions)
145+
135146
logger.info("'build' command executed.")
136147

137148

.generator/test_cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,15 @@ def test_handle_generate_fail(caplog):
117117
handle_generate()
118118

119119

120-
def test_handle_build_success(caplog, mock_generate_request_file):
120+
def test_handle_build_success(caplog, mocker):
121121
"""
122122
Tests the successful execution path of handle_build.
123123
"""
124124
caplog.set_level(logging.INFO)
125125

126+
mocker.patch(
127+
"cli._run_nox_sessions", return_value="mock-result"
128+
)
126129
handle_build()
127130

128131
assert "'build' command executed." in caplog.text

0 commit comments

Comments
 (0)