Skip to content

Commit 9b27bc2

Browse files
committed
✅ Fix pytest
1 parent 4a7aba7 commit 9b27bc2

File tree

3 files changed

+8
-33
lines changed

3 files changed

+8
-33
lines changed

src/repl_python_wakatime/backends/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ def get_project(
5252
project = cwd
5353
for parent in project.parents:
5454
for filename in filenames:
55-
if (parent / filename).exists():
56-
return project.name
55+
path = parent / filename
56+
if path.exists():
57+
return parent.name
5758
return cwd.name
5859

5960
def __or__(self, hook: Self) -> "Hook":

tests/test_api.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/test_project.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import os
66
from pathlib import Path
77

8-
from repl_python_wakatime.utils.project import get_project
8+
from repl_python_wakatime.backends import Hook
9+
10+
hook = Hook()
911

1012

1113
class Test:
@@ -22,7 +24,7 @@ def test_get_project_no_cwd(self, tmp_path: Path) -> None:
2224
os.makedirs(".svn")
2325
os.makedirs("subdir")
2426
os.chdir("subdir")
25-
rst = get_project([".git", ".svn"])
27+
rst = hook.get_project((".git/", ".svn/"))
2628
expected = os.path.basename(tmp_path)
2729
assert rst == expected
2830

@@ -36,6 +38,6 @@ def test_get_project_cwd(self, tmp_path: Path) -> None:
3638
os.chdir(tmp_path)
3739
os.makedirs("subdir")
3840
os.chdir("subdir")
39-
rst = get_project([".git", ".svn"])
41+
rst = hook.get_project((".git/", ".svn/"))
4042
expected = "subdir"
4143
assert rst == expected

0 commit comments

Comments
 (0)