Commit 46198c3
committed
Implements local Python SDK replacement functionality for testing Pulumi providers and programs with unpublished Python SDK builds. This feature enables developers to test against local Python SDKs using
1. **pulumitest/opttest/opttest.go**:
- Added `PythonLinks []string` field to `Options` struct to store local Python package paths
- Created `PythonLink()` function to accept one or more local Python package paths
- Updated `Defaults()` function to initialize `PythonLinks` slice
2. **pulumitest/newStack.go**:
- Implemented pip install logic to execute `python -m pip install -e <path>` for each Python package
- Uses absolute paths (consistent with GoModReplacement pattern)
- Executes after YarnLink and before GoModReplacement for logical ordering
- Includes proper error handling and logging
3. **pulumitest/opttest/opttest_test.go** (new file):
- `TestPythonLinkOption`: Verifies single package path is appended
- `TestPythonLinkMultiplePackages`: Verifies multiple package paths can be specified
- `TestPythonLinkAccumulates`: Verifies packages accumulate across multiple calls
- `TestDefaultsResetsPythonLinks`: Verifies Defaults() resets PythonLinks
4. **pulumitest/README.md**:
- Added "Python - Local Package Installation" section
- Documented PythonLink usage with examples
- Followed same documentation pattern as YarnLink and GoModReplacement sections
- **Editable Mode**: Uses `pip install -e` for symlinked/editable installation (same behavior as yarn link)
- **Multiple Packages**: Supports installing multiple local Python packages in a single test
- **Absolute Paths**: Converts relative paths to absolute paths for reliability
- **Error Handling**: Clear error messages if pip install fails or paths don't exist
- **Environment Aware**: Uses `python -m pip` for better virtual environment compatibility
- ✅ All unit tests for PythonLink option pass (4/4 tests)
- ✅ Code formatting passes (go fmt)
- ✅ Code vetting passes (go vet)
- ✅ Linting passes
- ✅ Implementation follows existing architectural patterns for YarnLink and GoModReplacement
```go
import (
"filepath"
"testing"
"github.com/pulumi/providertest/pulumitest"
"github.com/pulumi/providertest/pulumitest/opttest"
)
func TestWithLocalPythonSDK(t *testing.T) {
// Use local Python SDK build
test := pulumitest.NewPulumiTest(t, "test_dir",
opttest.PythonLink("../sdk/python"))
// Or multiple packages
test2 := pulumitest.NewPulumiTest(t, "test_dir",
opttest.PythonLink("../sdk/python", "../other-sdk/python"))
test.Up(t)
}
```pip install -e (editable mode), following the same pattern as existing YarnLink (Node.js) and GoModReplacement (Go) features.1 parent fe0a2a7 commit 46198c3
File tree
4 files changed
+176
-5
lines changed- pulumitest
- opttest
4 files changed
+176
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
134 | 151 | | |
135 | 152 | | |
136 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
86 | 90 | | |
87 | 91 | | |
88 | 92 | | |
| |||
148 | 152 | | |
149 | 153 | | |
150 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
151 | 171 | | |
152 | 172 | | |
153 | 173 | | |
| |||
170 | 190 | | |
171 | 191 | | |
172 | 192 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | 193 | | |
179 | 194 | | |
180 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
108 | 116 | | |
109 | 117 | | |
110 | 118 | | |
| |||
166 | 174 | | |
167 | 175 | | |
168 | 176 | | |
| 177 | + | |
169 | 178 | | |
170 | 179 | | |
171 | 180 | | |
| |||
200 | 209 | | |
201 | 210 | | |
202 | 211 | | |
| 212 | + | |
203 | 213 | | |
204 | 214 | | |
205 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
0 commit comments