Skip to content

Commit 972b8b8

Browse files
authored
Unify module path logic between django & unittest runner (#99)
Co-authored-by: Jakob Moosbrugger <>
1 parent b21f707 commit 972b8b8

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

lua/dap-python.lua

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,17 @@ local function load_dap()
9898
end
9999

100100

101-
---@private
102-
function M.test_runners.unittest(classname, methodname)
103-
local path
101+
local function get_module_path()
104102
if is_windows() then
105-
path = vim.fn.expand('%:.:r:gs?\\?.?')
103+
return vim.fn.expand('%:.:r:gs?\\?.?')
106104
else
107-
path = vim.fn.expand('%:.:r:gs?/?.?')
105+
return vim.fn.expand('%:.:r:gs?/?.?')
108106
end
107+
end
108+
109+
---@private
110+
function M.test_runners.unittest(classname, methodname)
111+
local path = get_module_path()
109112
local test_path = table.concat(prune_nil({path, classname, methodname}), '.')
110113
local args = {'-v', test_path}
111114
return 'unittest', args
@@ -124,7 +127,7 @@ end
124127

125128
---@private
126129
function M.test_runners.django(classname, methodname)
127-
local path = vim.fn.expand('%:r:gs?/?.?')
130+
local path = get_module_path()
128131
local test_path = table.concat(prune_nil({path, classname, methodname}), '.')
129132
local args = {'test', test_path}
130133
return 'django', args

0 commit comments

Comments
 (0)