Commit ced40b6
Fix test_nss.py import error when ng_model_gym is not installed (pytorch#17184)
Summary:
Fixes test collection failure in CI when `ng_model_gym` is not installed.
The `test_nss.py` file imports `ng_model_gym` at module level, which requires `pydantic`. In CI environments where these dependencies are not installed, pytest fails during test collection with `ModuleNotFoundError: No module named 'pydantic'`.
This fix adds `pytest.importorskip("ng_model_gym")` before the import, which gracefully skips the entire test module when the dependency is unavailable instead of failing test collection.
---
> Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Confucius Session](https://www.internalfb.com/confucius?host=44014.od.fbinfra.net&port=8086&tab=Chat&session_id=3841a0f6-014b-11f1-919a-6b37349122a8&entry_name=Code+Assist), [Trace](https://www.internalfb.com/confucius?session_id=3841a0f6-014b-11f1-919a-6b37349122a8&tab=Trace)
Differential Revision: D922062831 parent c0cef6c commit ced40b6
1 file changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | | - | |
20 | 18 | | |
21 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
0 commit comments