()
| 7 | /// project's configuration. Here, this is tested for the Python version. |
| 8 | #[test] |
| 9 | fn config_override_python_version() -> anyhow::Result<()> { |
| 10 | let case = CliTest::with_files([ |
| 11 | ( |
| 12 | "pyproject.toml", |
| 13 | r#" |
| 14 | [tool.ty.environment] |
| 15 | python-version = "3.11" |
| 16 | "#, |
| 17 | ), |
| 18 | ( |
| 19 | "test.py", |
| 20 | r#" |
| 21 | import sys |
| 22 | |
| 23 | # Access `sys.last_exc` that was only added in Python 3.12 |
| 24 | print(sys.last_exc) |
| 25 | "#, |
| 26 | ), |
| 27 | ])?; |
| 28 | |
| 29 | assert_cmd_snapshot!(case.command(), @r#" |
| 30 | success: false |
| 31 | exit_code: 1 |
| 32 | ----- stdout ----- |
| 33 | error[missing-attribute]: Module `sys` has no member `last_exc` |
| 34 | --> test.py:5:7 |
| 35 | | |
| 36 | 5 | print(sys.last_exc) |
| 37 | | ^^^^^^^^^^^^ |
| 38 | info: The member may be available on other Python versions or platforms |
| 39 | info: Python 3.11 was assumed when resolving the `last_exc` attribute |
| 40 | --> pyproject.toml:3:18 |
| 41 | | |
| 42 | 3 | python-version = "3.11" |
| 43 | | ^^^^^^ Python version configuration |
| 44 | |
| 45 | Found 1 diagnostic |
| 46 | |
| 47 | ----- stderr ----- |
| 48 | "#); |
| 49 | |
| 50 | assert_cmd_snapshot!(case.command().arg("--python-version").arg("3.12"), @" |
| 51 | success: true |
| 52 | exit_code: 0 |
| 53 | ----- stdout ----- |
| 54 | All checks passed! |
| 55 | |
| 56 | ----- stderr ----- |
| 57 | "); |
| 58 | |
| 59 | Ok(()) |
| 60 | } |
| 61 | |
| 62 | /// Same as above, but for the Python platform. |
| 63 | #[test] |
nothing calls this directly
no test coverage detected