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

Method TestUv

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

Source from the content-addressed store, hash-verified

784}
785
786func (PythonSuite) TestUv(ctx context.Context, t *testctx.T) {
787 t.Run("disabled", func(ctx context.Context, t *testctx.T) {
788 c := connect(ctx, t)
789
790 ctr, err := daggerCliBase(t, c).
791 With(pyprojectExtra(nil, `
792 [tool.dagger]
793 use-uv = false
794 `)).
795 With(daggerInitPython()).
796 // Only uv creates a lock
797 WithExec([]string{"test", "!", "-f", "uv.lock"}).
798 WithExec([]string{"test", "!", "-f", "requirements.lock"}).
799 Sync(ctx)
800
801 require.NoError(t, err)
802
803 // Should still work with pip though
804 out, err := ctr.
805 With(daggerCall("container-echo", "--string-arg=hello", "stdout")).
806 Stdout(ctx)
807
808 require.NoError(t, err)
809 require.Equal(t, "hello\n", out)
810 })
811
812 t.Run("disabled, check pip install", func(ctx context.Context, t *testctx.T) {
813 // `pip check` fails if Requires-Python doesn't match the
814 // Python version in the container
815
816 c := connect(ctx, t)
817
818 out, err := daggerCliBase(t, c).
819 With(pyprojectExtra(nil, `
820 requires-python = "<3.11"
821
822 [tool.dagger]
823 use-uv = false
824 `)).
825 With(daggerInitPython()).
826 With(daggerCall("container-echo", "--string-arg=hello", "stdout")).
827 Stdout(ctx)
828
829 t.Logf("out: %s", out)
830 requireErrOut(t, err, "pip is looking at multiple versions of test")
831 requireErrOut(t, err, "requires a different Python")
832 })
833
834 t.Run("pinned version", func(ctx context.Context, t *testctx.T) {
835 c := connect(ctx, t)
836
837 source := pythonSource(`
838import anyio
839import dagger
840
841@dagger.object_type
842class Test:
843 @dagger.function

Callers

nothing calls this directly

Calls 13

daggerCliBaseFunction · 0.85
pyprojectExtraFunction · 0.85
daggerInitPythonFunction · 0.85
daggerCallFunction · 0.85
requireErrOutFunction · 0.85
pythonSourceFunction · 0.85
connectFunction · 0.70
RunMethod · 0.65
SyncMethod · 0.65
EqualMethod · 0.65
WithExecMethod · 0.45
WithMethod · 0.45

Tested by

no test coverage detected