Attempt at making BAT work on Windows
All BlendPath instances will use forward slashes, and there should be more use of PurePosixPath instead of Path.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from pathlib import Path
|
||||
from pathlib import Path, PurePosixPath
|
||||
import unittest
|
||||
|
||||
from blender_asset_tracer.bpathlib import BlendPath
|
||||
@@ -6,11 +6,12 @@ from blender_asset_tracer.bpathlib import BlendPath
|
||||
|
||||
class BlendPathTest(unittest.TestCase):
|
||||
def test_string_path(self):
|
||||
p = BlendPath(Path('//some/file.blend'))
|
||||
p = BlendPath(PurePosixPath('//some/file.blend'))
|
||||
self.assertEqual('//some/file.blend', str(PurePosixPath('//some/file.blend')))
|
||||
self.assertEqual(b'//some/file.blend', p)
|
||||
|
||||
p = BlendPath(Path(r'C:\some\file.blend'))
|
||||
self.assertEqual(b'C:\\some\\file.blend', p)
|
||||
self.assertEqual(b'C:/some/file.blend', p)
|
||||
|
||||
def test_is_absolute(self):
|
||||
self.assertFalse(BlendPath(b'//some/file.blend').is_absolute())
|
||||
|
||||
+4
-3
@@ -162,7 +162,7 @@ class PackTest(AbstractPackTest):
|
||||
def test_execute_rewrite(self):
|
||||
infile, _ = self._pack_with_rewrite()
|
||||
|
||||
extpath = pathlib.Path('//_outside_project', *self.blendfiles.parts[1:])
|
||||
extpath = pathlib.PurePosixPath('//_outside_project', *self.blendfiles.parts[1:])
|
||||
extbpath = bpathlib.BlendPath(extpath)
|
||||
|
||||
# Those libraries should be properly rewritten.
|
||||
@@ -209,8 +209,9 @@ class PackTest(AbstractPackTest):
|
||||
seq = ed.get_pointer((b'seqbase', b'first'))
|
||||
seq_strip = seq.get_pointer(b'strip')
|
||||
|
||||
as_bytes = str((self.blendfiles / 'imgseq').absolute()).encode()
|
||||
relpath = b'//_outside_project%b' % as_bytes
|
||||
imgseq_path = (self.blendfiles / 'imgseq').absolute()
|
||||
as_bytes = str(imgseq_path.relative_to(imgseq_path.anchor)).encode()
|
||||
relpath = bpathlib.BlendPath(b'//_outside_project') / as_bytes
|
||||
|
||||
# The image sequence base path should be rewritten.
|
||||
self.assertEqual(b'SQ000210.png', seq[b'name'])
|
||||
|
||||
Reference in New Issue
Block a user