Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
("seq/foo_#_extra.exr", None),
("seq/foo_##.exr", None),
("seq/foo_@.exr", None),
("seq/big.#.ext", "seq/big.999-1003#.ext"),
("seq/big.@@@.ext", "seq/big.1000-1003@@@.ext"),
("seq/big.@.ext", "seq/big.1000-1003@.ext"),
("seq/big.#@.ext", None),
]
for pattern, expected in tests:
if expected is None:
with self.assertRaises(FileSeqException):
findSequenceOnDisk(pattern, strictPadding=True)
continue
seq = findSequenceOnDisk(pattern, strictPadding=True)
self.assertTrue(isinstance(seq, FileSequence))
actual = str(seq)
self.assertEqual(actual, expected)
("seq/foo.debug.#.exr", "seq/foo.debug.1-5#.exr"),
("seq/#.exr", "seq/1-3#.exr"),
("seq/foo_#.exr", "seq/foo_1#.exr"),
("seq/foo_#_extra.exr", None),
("seq/foo_##.exr", None),
("seq/foo_@.exr", None),
("seq/big.#.ext", "seq/big.999-1003#.ext"),
("seq/big.@@@.ext", "seq/big.1000-1003@@@.ext"),
("seq/big.@.ext", "seq/big.1000-1003@.ext"),
("seq/big.#@.ext", None),
]
for pattern, expected in tests:
if expected is None:
with self.assertRaises(FileSeqException):
findSequenceOnDisk(pattern, strictPadding=True)
continue
seq = findSequenceOnDisk(pattern, strictPadding=True)
self.assertTrue(isinstance(seq, FileSequence))
actual = str(seq)
self.assertEqual(actual, expected)
("mixed/seq.#.ext", "mixed/seq.-1-5#.ext"),
("mixed/seq.@@.ext", "mixed/seq.-1-5@@.ext"),
("mixed/seq.@@@@@.ext", "mixed/seq.-1-5@@@@@.ext"),
("mixed/seq.@.ext", "mixed/seq.-1@.ext"),
("mixed/seq.##.ext", None),
("mixed/seq.%04d.ext", "mixed/seq.-1-5#.ext"),
("mixed/seq.%02d.ext", "mixed/seq.-1-5@@.ext"),
("mixed/seq.%05d.ext", "mixed/seq.-1-5@@@@@.ext"),
("mixed/seq.%01d.ext", "mixed/seq.-1@.ext"),
("mixed/seq.%08d.ext", None),
]
for pattern, expected in tests:
if expected is None:
with self.assertRaises(FileSeqException):
findSequenceOnDisk(pattern, strictPadding=True)
continue
seq = findSequenceOnDisk(pattern, strictPadding=True)
self.assertTrue(isinstance(seq, FileSequence))
actual = str(seq)
self.assertEqual(actual, expected)
("mixed/seq.@.ext", "mixed/seq.-1@.ext"),
("mixed/seq.##.ext", None),
("mixed/seq.%04d.ext", "mixed/seq.-1-5#.ext"),
("mixed/seq.%02d.ext", "mixed/seq.-1-5@@.ext"),
("mixed/seq.%05d.ext", "mixed/seq.-1-5@@@@@.ext"),
("mixed/seq.%01d.ext", "mixed/seq.-1@.ext"),
("mixed/seq.%08d.ext", None),
]
for pattern, expected in tests:
if expected is None:
with self.assertRaises(FileSeqException):
findSequenceOnDisk(pattern, strictPadding=True)
continue
seq = findSequenceOnDisk(pattern, strictPadding=True)
self.assertTrue(isinstance(seq, FileSequence))
actual = str(seq)
self.assertEqual(actual, expected)
def testFindSequenceOnDisk(self):
tests = [
("seq/bar#.exr", "seq/bar1000-1002,1004-1006#.exr"),
("seq/foo.#.exr", "seq/foo.1-5#.exr"),
("seq/foo.#.jpg", "seq/foo.1-5#.jpg"),
("seq/foo.0002.jpg", "seq/foo.1-5#.jpg"),
("seq/foo.#.exr", "seq/foo.1-5#.exr"),
("seq/foo.debug.#.exr", "seq/foo.debug.1-5#.exr"),
("seq/#.exr", "seq/1-3#.exr"),
("seq/bar1001.exr", "seq/bar1001.exr"),
("seq/foo_0001.exr", "seq/foo_0001.exr"),
]
for pattern, expected in tests:
seq = findSequenceOnDisk(pattern, strictPadding=False)
self.assertTrue(isinstance(seq, FileSequence))
actual = str(seq)
self.assertEqual(actual, expected)
("seq/foo.#.exr", "seq\\foo.1-5#.exr"),
("seq/foo.debug.#.exr", "seq\\foo.debug.1-5#.exr"),
("seq/#.exr", "seq\\1-3#.exr"),
("seq/bar1001.exr", "seq/bar1001.exr"),
("seq/foo_0001.exr", "seq/foo_0001.exr"),
]
import ntpath
_path = os.path
os.path = ntpath
try:
self.assertEqual(os.path.join('a', 'b'), 'a\\b')
for pattern, expected in tests:
seq = findSequenceOnDisk(pattern)
self.assertTrue(isinstance(seq, FileSequence))
actual = str(seq)
self.assertEqual(actual, expected)
finally:
os.path = _path