Browse Source

Merge pull request #21 from tomlowshang/trailing_slash

Bastien Sevajol 6 years ago
parent
commit
04f65caeb7
No account linked to committer's email
2 changed files with 7 additions and 1 deletions
  1. 2 1
      synergine2_cocos2d/util.py
  2. 5 0
      tests/test_utils.py

+ 2 - 1
synergine2_cocos2d/util.py View File

@@ -10,7 +10,8 @@ from synergine2_cocos2d.exception import FileNotFound
10 10
 
11 11
 def get_map_file_path_from_dir(map_dir_path: str) -> str:
12 12
     # TODO: path is temp here
13
-    return '{}.tmx'.format(os.path.join(map_dir_path, os.path.basename(map_dir_path)))
13
+    return '{}.tmx'.format(os.path.join(map_dir_path,
14
+        os.path.basename(map_dir_path.rstrip('/'))))
14 15
 
15 16
 
16 17
 class PathManager(object):

+ 5 - 0
tests/test_utils.py View File

@@ -6,6 +6,7 @@ import pytest
6 6
 from synergine2.utils import ChunkManager
7 7
 from synergine2_cocos2d.exception import FileNotFound
8 8
 from synergine2_cocos2d.util import PathManager
9
+from synergine2_cocos2d.util import get_map_file_path_from_dir
9 10
 from tests import BaseTest
10 11
 
11 12
 
@@ -44,3 +45,7 @@ class TestUtils(BaseTest):
44 45
         path_manager.add_included_path('tests/fixtures/some_media2')
45 46
         # it is prior on path finding
46 47
         assert 'tests/fixtures/some_media2/foo.txt' == path_manager.path('foo.txt')
48
+
49
+    def test_get_map_file_path_from_dir(self):
50
+        assert get_map_file_path_from_dir('map/003') == 'map/003/003.tmx'
51
+        assert get_map_file_path_from_dir('map/003/') == 'map/003/003.tmx'