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
 
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 View File

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'