(ctx context.Context, t *testctx.T)
| 593 | } |
| 594 | |
| 595 | func (PythonSuite) TestVersion(ctx context.Context, t *testctx.T) { |
| 596 | // NB: All "pinned" and "relaxed" tests intentionally choose patch versions that |
| 597 | // are not the latest, and major versions that aren't the default in the runtime. |
| 598 | |
| 599 | source := pythonSource(` |
| 600 | import sys |
| 601 | import dagger |
| 602 | |
| 603 | @dagger.object_type |
| 604 | class Test: |
| 605 | @dagger.function |
| 606 | def pinned(self) -> str: |
| 607 | v = sys.version_info |
| 608 | return f"{v.major}.{v.minor}.{v.micro}" |
| 609 | |
| 610 | @dagger.function |
| 611 | def relaxed(self) -> str: |
| 612 | v = sys.version_info |
| 613 | return f"{v.major}.{v.minor}" |
| 614 | `, |
| 615 | ) |
| 616 | |
| 617 | t.Run("relaxed requires-python", func(ctx context.Context, t *testctx.T) { |
| 618 | c := connect(ctx, t) |
| 619 | |
| 620 | out, err := daggerCliBase(t, c). |
| 621 | With(pyprojectExtra(nil, `requires-python = ">=3.11"`)). |
| 622 | With(source). |
| 623 | With(daggerInitPython()). |
| 624 | With(daggerCall("relaxed")). |
| 625 | Stdout(ctx) |
| 626 | |
| 627 | require.NoError(t, err) |
| 628 | require.Equal(t, "3.11", out) |
| 629 | }) |
| 630 | |
| 631 | t.Run("pinned requires-python", func(ctx context.Context, t *testctx.T) { |
| 632 | c := connect(ctx, t) |
| 633 | |
| 634 | out, err := daggerCliBase(t, c). |
| 635 | // Space after `==` is intentional. |
| 636 | With(pyprojectExtra(nil, `requires-python = "== 3.11.6"`)). |
| 637 | With(source). |
| 638 | With(daggerInitPython()). |
| 639 | With(daggerCall("pinned")). |
| 640 | Stdout(ctx) |
| 641 | |
| 642 | require.NoError(t, err) |
| 643 | require.Equal(t, "3.11.6", out) |
| 644 | }) |
| 645 | |
| 646 | t.Run("relaxed .python-version", func(ctx context.Context, t *testctx.T) { |
| 647 | c := connect(ctx, t) |
| 648 | |
| 649 | out, err := daggerCliBase(t, c). |
| 650 | With(source). |
| 651 | With(pyprojectExtra(nil, `requires-python = ">=3.10"`)). |
| 652 | With(fileContents(".python-version", "3.11")). |
nothing calls this directly
no test coverage detected