Skip to content

Commit

Permalink
fix macos directory issue when finding project root
Browse files Browse the repository at this point in the history
  • Loading branch information
YajJackson committed Apr 13, 2024
1 parent 9289fb7 commit 91d4d7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 4 additions & 3 deletions godot_parser/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Utils """

import json
import os
from typing import Optional
Expand Down Expand Up @@ -27,9 +28,9 @@ def stringify_object(value):


def find_project_root(start: str) -> Optional[str]:
curdir = start
if os.path.isfile(start):
curdir = os.path.dirname(start)
curdir = os.path.realpath(start) # Ensure start is a real path
if os.path.isfile(curdir):
curdir = os.path.dirname(curdir)
while True:
if os.path.isfile(os.path.join(curdir, "project.godot")):
return curdir
Expand Down
5 changes: 1 addition & 4 deletions tests/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class TestTree(unittest.TestCase):

"""Test the the high-level tree API"""

def test_get_node(self):
Expand Down Expand Up @@ -107,7 +106,6 @@ def test_dunder(self):


class TestInheritedScenes(unittest.TestCase):

"""Test the the high-level tree API for inherited scenes"""

project_dir = None
Expand All @@ -118,7 +116,7 @@ class TestInheritedScenes(unittest.TestCase):
@classmethod
def setUpClass(cls):
super(TestInheritedScenes, cls).setUpClass()
cls.project_dir = tempfile.mkdtemp()
cls.project_dir = os.path.realpath(tempfile.mkdtemp())
with open(
os.path.join(cls.project_dir, "project.godot"), "w", encoding="utf-8"
) as ofile:
Expand Down Expand Up @@ -300,7 +298,6 @@ def test_missing_ext_resource(self):


class TestUtil(unittest.TestCase):

"""Tests for util"""

def test_bad_gdpath(self):
Expand Down

0 comments on commit 91d4d7f

Please sign in to comment.