MCPcopy Create free account
hub / github.com/astral-sh/ruff / default_root_python_package

Function default_root_python_package

crates/ty/tests/cli/python_environment.rs:2140–2177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2138/// If `python/__init__.py` is present, it is considered a package and `python` is not added to search paths.
2139#[test]
2140fn default_root_python_package() -> anyhow::Result<()> {
2141 let case = CliTest::with_files([
2142 ("src/foo.py", "foo = 10"),
2143 ("python/__init__.py", ""),
2144 ("python/bar.py", "bar = 20"),
2145 (
2146 "python/test_bar.py",
2147 r#"
2148 from foo import foo
2149 from bar import bar # expected unresolved import
2150
2151 print(f"{foo} {bar}")
2152 "#,
2153 ),
2154 ])?;
2155
2156 assert_cmd_snapshot!(case.command(), @"
2157 success: false
2158 exit_code: 1
2159 ----- stdout -----
2160 error[import-not-found]: Cannot resolve imported module `bar`
2161 --> python/test_bar.py:3:6
2162 |
2163 3 | from bar import bar # expected unresolved import
2164 | ^^^
2165 info: Searched in the following paths during module resolution:
2166 info: 1. <temp_dir>/src (first-party code)
2167 info: 2. <temp_dir>/ (first-party code)
2168 info: 3. vendored://stdlib (stdlib typeshed stubs vendored by ty)
2169 info: make sure your Python environment is properly configured: https://docs.astral.sh/ty/modules/#python-environment
2170
2171 Found 1 diagnostic
2172
2173 ----- stderr -----
2174 ");
2175
2176 Ok(())
2177}
2178
2179/// Similarly, if `python/__init__.pyi` is present, it is considered a package and `python` is not added to search paths.
2180#[test]

Callers

nothing calls this directly

Calls 2

with_filesFunction · 0.85
OkClass · 0.85

Tested by

no test coverage detected