From 266fc5671fff3f2c251ccfc649eda9282418bedb Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Wed, 5 Oct 2022 08:03:43 +0200 Subject: [PATCH] fix(python): do not validate empty env --- src/segments/python.go | 6 +++--- src/segments/python_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/segments/python.go b/src/segments/python.go index aca3202d..3a3ae94f 100644 --- a/src/segments/python.go +++ b/src/segments/python.go @@ -70,6 +70,9 @@ func (p *Python) loadContext() { var venv string for _, venvVar := range venvVars { venv = p.language.env.Getenv(venvVar) + if len(venv) == 0 { + continue + } name := environment.Base(p.language.env, venv) if p.canUseVenvName(name) { p.Venv = name @@ -83,9 +86,6 @@ func (p *Python) inContext() bool { } func (p *Python) canUseVenvName(name string) bool { - if name == "" || name == "." { - return false - } if p.language.props.GetBool(properties.DisplayDefault, true) { return true } diff --git a/src/segments/python_test.go b/src/segments/python_test.go index f85f875e..25d58680 100644 --- a/src/segments/python_test.go +++ b/src/segments/python_test.go @@ -121,7 +121,7 @@ func TestPythonPythonInContext(t *testing.T) { for _, tc := range cases { env := new(mock.MockedEnvironment) env.On("GOOS").Return("") - env.On("PathSeparator").Return("") + env.On("PathSeparator").Return("/") env.On("Getenv", "VIRTUAL_ENV").Return(tc.VirtualEnvName) env.On("Getenv", "CONDA_ENV_PATH").Return("") env.On("Getenv", "CONDA_DEFAULT_ENV").Return("")