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