MCPcopy Create free account
hub / github.com/dagger/dagger / TestVersion

Method TestVersion

core/integration/module_python_test.go:595–724  ·  view source on GitHub ↗
(ctx context.Context, t *testctx.T)

Source from the content-addressed store, hash-verified

593}
594
595func (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(`
600import sys
601import dagger
602
603@dagger.object_type
604class 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")).

Callers

nothing calls this directly

Calls 11

pythonSourceFunction · 0.85
daggerCliBaseFunction · 0.85
pyprojectExtraFunction · 0.85
daggerInitPythonFunction · 0.85
daggerCallFunction · 0.85
fileContentsFunction · 0.85
connectFunction · 0.70
RunMethod · 0.65
EqualMethod · 0.65
StdoutMethod · 0.45
WithMethod · 0.45

Tested by

no test coverage detected