vault backup: 2025-01-10 15:32:19

This commit is contained in:
deng 2025-01-10 15:32:19 +08:00
parent fd1f224809
commit f4b3381c8e
2 changed files with 8 additions and 4 deletions

View File

@ -147,6 +147,7 @@
"active": "e0251782d53c0c60",
"lastOpenFiles": [
"組織/EverfortuneAI/{Note} Packaging Python Project.md",
"組織/EverfortuneAI/{Note} Nox.md",
"README.md",
"Test.md",
"組織/EverfortuneAI/resources/should_setup_py_be_deleted.png",

View File

@ -13,12 +13,15 @@ tags:
[image resource](https://nox.thea.codes/en/stable/index.html)
- Abstract
- 在將Python專案打包時會遇到填寫依賴套件及其版本的問題開發者必須逐一測試Python版本與依賴套件版本之間甚至是跨平台不同組合的可運行性而Nox正是為了可以將此流程自動化而生
- 在將Python專案打包時會遇到填寫依賴套件及其版本的問題開發者必須逐一測試Python版本與依賴套件版本之間甚至是跨平台不同組合的可運行性而Nox可以將這一流程自動化
- Steps
1. 在虛擬環境中安裝Nox`pip install nox`
1. 在開發環境中安裝Nox`python -m pip install nox`
2. 在Package資料夾中產生*noxfile.py* 並撰寫測試程式碼範例程式碼可見Note
3. 於終端機輸入`nox` 開始進行測試
- Note
- 若只想執行某個函式的程式碼,可執行`nox -s [function_name]`
- 若想將測試結果輸出檔案,可執行`nox --report [file_name].json`
- 小知識如果semantic version沒有給patch的話則其為0比方說我們要測試的numpy版本設為1.24則其實際測試的版本為1.24.0
- 以下為*noxfile.py*範例程式碼(透過環境是否能順利通過單元測試來判別套件之間的匹配性)
```python
@ -30,7 +33,7 @@ tags:
import nox
@nox.session(python=['3.10', '3.11', '3.12'])
@nox.session(venv_backend='conda', python=['3.10', '3.11', '3.12'])
@nox.parametrize('numpy', ['1.26', '2.0'])
@nox.parametrize('scikit_learn', ['1.5', '1.6'])
def test_flexibility(session, numpy, scikit_learn):
@ -41,5 +44,5 @@ def test_flexibility(session, numpy, scikit_learn):
# Test
session.install('pytest')
session.run('pytest')
session.run('pytest', 'tests', '-v')
```