浏览代码

Merge pull request #21 from tomlowshang/trailing_slash

Bastien Sevajol 6 年前
父节点
当前提交
04f65caeb7
没有帐户链接到提交者的电子邮件
共有 2 个文件被更改,包括 7 次插入1 次删除
  1. 2 1
      synergine2_cocos2d/util.py
  2. 5 0
      tests/test_utils.py

+ 2 - 1
synergine2_cocos2d/util.py 查看文件

10
 
10
 
11
 def get_map_file_path_from_dir(map_dir_path: str) -> str:
11
 def get_map_file_path_from_dir(map_dir_path: str) -> str:
12
     # TODO: path is temp here
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
 class PathManager(object):
17
 class PathManager(object):

+ 5 - 0
tests/test_utils.py 查看文件

6
 from synergine2.utils import ChunkManager
6
 from synergine2.utils import ChunkManager
7
 from synergine2_cocos2d.exception import FileNotFound
7
 from synergine2_cocos2d.exception import FileNotFound
8
 from synergine2_cocos2d.util import PathManager
8
 from synergine2_cocos2d.util import PathManager
9
+from synergine2_cocos2d.util import get_map_file_path_from_dir
9
 from tests import BaseTest
10
 from tests import BaseTest
10
 
11
 
11
 
12
 
44
         path_manager.add_included_path('tests/fixtures/some_media2')
45
         path_manager.add_included_path('tests/fixtures/some_media2')
45
         # it is prior on path finding
46
         # it is prior on path finding
46
         assert 'tests/fixtures/some_media2/foo.txt' == path_manager.path('foo.txt')
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'