Mercurial > hgrepos > Python > apps > py-cutils
comparison tests/test_walk.py @ 289:79deb10bbe0a
Add some new unittests for special chars (CR/LF) in paths
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 24 Feb 2025 02:53:58 +0100 |
| parents | 99b78fa04bc1 |
| children | 7f797d71bd5e |
comparison
equal
deleted
inserted
replaced
| 288:57102b9d7ec9 | 289:79deb10bbe0a |
|---|---|
| 195 self.assertEqual(b"tests\xc3\x85/test", entry.u8path) | 195 self.assertEqual(b"tests\xc3\x85/test", entry.u8path) |
| 196 | 196 |
| 197 self.assertEqual(b"test", entry.alt_u8name) | 197 self.assertEqual(b"test", entry.alt_u8name) |
| 198 self.assertEqual(b"tests\\xc5/test", entry.alt_u8path) | 198 self.assertEqual(b"tests\\xc5/test", entry.alt_u8path) |
| 199 | 199 |
| 200 def test_special_chars_name(self): | |
| 201 entry = walk.WalkDirEntry.from_path_name( | |
| 202 "testdir", "test\r-\n-\\rest", _do_stat=False) | |
| 203 self.assertEqual(u"test\r-\n-\\rest", entry.uname) | |
| 204 self.assertIsNone(entry.fsname) | |
| 205 self.assertIsNone(entry.u8name) | |
| 206 self.assertEqual(b"test\\x0d-\\x0a-\\x5crest", entry.alt_fsname) | |
| 207 self.assertEqual(b"test\\x0d-\\x0a-\\x5crest", entry.alt_u8name) | |
| 208 | |
| 209 def test_special_chars_path(self): | |
| 210 entry = walk.WalkDirEntry.from_path_name( | |
| 211 "testdir-\r-\n-rest", "testfile", _do_stat=False) | |
| 212 self.assertEqual(u"testdir-\r-\n-rest/testfile", entry.upath) | |
| 213 self.assertIsNone(entry.fspath) | |
| 214 self.assertIsNone(entry.u8path) | |
| 215 self.assertEqual(b"testdir-\\x0d-\\x0a-rest/testfile", | |
| 216 entry.alt_fspath) | |
| 217 self.assertEqual(b"testdir-\\x0d-\\x0a-rest/testfile", | |
| 218 entry.alt_u8path) | |
| 219 | |
| 220 def test_special_chars_fullpath(self): | |
| 221 entry = walk.WalkDirEntry.from_path_name( | |
| 222 "testdir-\r-\n-rest", "test-\n-\r-file", _do_stat=False) | |
| 223 self.assertEqual(u"testdir-\r-\n-rest/test-\n-\r-file", entry.upath) | |
| 224 self.assertIsNone(entry.fspath) | |
| 225 self.assertIsNone(entry.u8path) | |
| 226 self.assertEqual(b"testdir-\\x0d-\\x0a-rest/test-\\x0a-\\x0d-file", | |
| 227 entry.alt_fspath) | |
| 228 self.assertEqual(b"testdir-\\x0d-\\x0a-rest/test-\\x0a-\\x0d-file", | |
| 229 entry.alt_u8path) | |
| 230 | |
| 200 | 231 |
| 201 # https://stackoverflow.com/questions/1854/how-to-identify-which-os-python-is-running-on/58071295#58071295 | 232 # https://stackoverflow.com/questions/1854/how-to-identify-which-os-python-is-running-on/58071295#58071295 |
| 202 @unittest.skipIf( | 233 @unittest.skipIf( |
| 203 os.name != "posix", "Only supported on POSIX (needs real symlinks)") | 234 os.name != "posix", "Only supported on POSIX (needs real symlinks)") |
| 204 class SymlinkTests(unittest.TestCase): | 235 class SymlinkTests(unittest.TestCase): |
