()
| 2219 | |
| 2220 | #[test] |
| 2221 | fn pythonpath_is_respected() -> anyhow::Result<()> { |
| 2222 | let case = CliTest::with_files([ |
| 2223 | ("baz-dir/baz.py", "it = 42"), |
| 2224 | ( |
| 2225 | "src/foo.py", |
| 2226 | r#" |
| 2227 | import baz |
| 2228 | print(f"{baz.it}") |
| 2229 | "#, |
| 2230 | ), |
| 2231 | ])?; |
| 2232 | |
| 2233 | assert_cmd_snapshot!(case.command(), |
| 2234 | @" |
| 2235 | success: false |
| 2236 | exit_code: 1 |
| 2237 | ----- stdout ----- |
| 2238 | error[import-not-found]: Cannot resolve imported module `baz` |
| 2239 | --> src/foo.py:2:8 |
| 2240 | | |
| 2241 | 2 | import baz |
| 2242 | | ^^^ |
| 2243 | info: Searched in the following paths during module resolution: |
| 2244 | info: 1. <temp_dir>/src (first-party code) |
| 2245 | info: 2. <temp_dir>/ (first-party code) |
| 2246 | info: 3. vendored://stdlib (stdlib typeshed stubs vendored by ty) |
| 2247 | info: make sure your Python environment is properly configured: https://docs.astral.sh/ty/modules/#python-environment |
| 2248 | |
| 2249 | Found 1 diagnostic |
| 2250 | |
| 2251 | ----- stderr ----- |
| 2252 | "); |
| 2253 | |
| 2254 | assert_cmd_snapshot!(case.command() |
| 2255 | .env("PYTHONPATH", case.root().join("baz-dir")), |
| 2256 | @" |
| 2257 | success: true |
| 2258 | exit_code: 0 |
| 2259 | ----- stdout ----- |
| 2260 | All checks passed! |
| 2261 | |
| 2262 | ----- stderr ----- |
| 2263 | "); |
| 2264 | |
| 2265 | Ok(()) |
| 2266 | } |
| 2267 | |
| 2268 | #[test] |
| 2269 | fn pythonpath_multiple_dirs_is_respected() -> anyhow::Result<()> { |
nothing calls this directly
no test coverage detected