Skip to content

Commit b703500

Browse files
[anaconda / miniconda] Update tests (devcontainers#842)
* [anaconda] Update tests - Rework test for checking the `tornado` package version; - Rework `checkPythonPackageVersion` function to use `importlib.metadata` library; * [miniconda] Update `test-utils.sh` - Rework `checkPythonPackageVersion` function to use `importlib.metadata` library;
1 parent 27499fd commit b703500

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

src/anaconda/test-project/test-utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ checkPythonPackageVersion()
168168
PACKAGE=$1
169169
REQUIRED_VERSION=$2
170170

171-
current_version=$(python -c "import ${PACKAGE}; print(${PACKAGE}.__version__)")
171+
current_version=$(python -c "import importlib.metadata; print(importlib.metadata.version('${PACKAGE}'))")
172172
check-version-ge "${PACKAGE}-requirement" "${current_version}" "${REQUIRED_VERSION}"
173173
}
174174

src/anaconda/test-project/test.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ checkPythonPackageVersion "transformers" "4.30.0"
4545
checkPythonPackageVersion "mpmath" "1.3.0"
4646
checkPythonPackageVersion "aiohttp" "3.8.5"
4747
checkPythonPackageVersion "jupyter_server" "2.7.2"
48-
49-
# The `tornado` package doesn't have the `__version__` attribute so we can use the `version` attribute.
50-
tornado_version=$(python -c "import tornado; print(tornado.version)")
51-
check-version-ge "tornado-requirement" "${tornado_version}" "6.3.3"
48+
checkPythonPackageVersion "tornado" "6.3.3"
5249

5350
checkCondaPackageVersion "pyopenssl" "23.2.0"
5451
checkCondaPackageVersion "cryptography" "41.0.3"

src/miniconda/test-project/test-utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ checkPythonPackageVersion()
169169
PACKAGE=$1
170170
REQUIRED_VERSION=$2
171171

172-
current_version=$(python -c "import ${PACKAGE}; print(${PACKAGE}.__version__)")
172+
current_version=$(python -c "import importlib.metadata; print(importlib.metadata.version('${PACKAGE}'))")
173173
check-version-ge "${PACKAGE}-requirement" "${current_version}" "${REQUIRED_VERSION}"
174174
}
175175

0 commit comments

Comments
 (0)