(self)
| 1846 | |
| 1847 | @needs_symlinks |
| 1848 | def test_resolve_common(self): |
| 1849 | P = self.cls |
| 1850 | p = P(self.base, 'foo') |
| 1851 | with self.assertRaises(OSError) as cm: |
| 1852 | p.resolve(strict=True) |
| 1853 | self.assertEqual(cm.exception.errno, errno.ENOENT) |
| 1854 | # Non-strict |
| 1855 | parser = self.parser |
| 1856 | self.assertEqualNormCase(str(p.resolve(strict=False)), |
| 1857 | parser.join(self.base, 'foo')) |
| 1858 | p = P(self.base, 'foo', 'in', 'spam') |
| 1859 | self.assertEqualNormCase(str(p.resolve(strict=False)), |
| 1860 | parser.join(self.base, 'foo', 'in', 'spam')) |
| 1861 | p = P(self.base, '..', 'foo', 'in', 'spam') |
| 1862 | self.assertEqualNormCase(str(p.resolve(strict=False)), |
| 1863 | parser.join(parser.dirname(self.base), 'foo', 'in', 'spam')) |
| 1864 | # These are all relative symlinks. |
| 1865 | p = P(self.base, 'dirB', 'fileB') |
| 1866 | self._check_resolve_relative(p, p) |
| 1867 | p = P(self.base, 'linkA') |
| 1868 | self._check_resolve_relative(p, P(self.base, 'fileA')) |
| 1869 | p = P(self.base, 'dirA', 'linkC', 'fileB') |
| 1870 | self._check_resolve_relative(p, P(self.base, 'dirB', 'fileB')) |
| 1871 | p = P(self.base, 'dirB', 'linkD', 'fileB') |
| 1872 | self._check_resolve_relative(p, P(self.base, 'dirB', 'fileB')) |
| 1873 | # Non-strict |
| 1874 | p = P(self.base, 'dirA', 'linkC', 'fileB', 'foo', 'in', 'spam') |
| 1875 | self._check_resolve_relative(p, P(self.base, 'dirB', 'fileB', 'foo', 'in', |
| 1876 | 'spam'), False) |
| 1877 | p = P(self.base, 'dirA', 'linkC', '..', 'foo', 'in', 'spam') |
| 1878 | if self.cls.parser is not posixpath: |
| 1879 | # In Windows, if linkY points to dirB, 'dirA\linkY\..' |
| 1880 | # resolves to 'dirA' without resolving linkY first. |
| 1881 | self._check_resolve_relative(p, P(self.base, 'dirA', 'foo', 'in', |
| 1882 | 'spam'), False) |
| 1883 | else: |
| 1884 | # In Posix, if linkY points to dirB, 'dirA/linkY/..' |
| 1885 | # resolves to 'dirB/..' first before resolving to parent of dirB. |
| 1886 | self._check_resolve_relative(p, P(self.base, 'foo', 'in', 'spam'), False) |
| 1887 | # Now create absolute symlinks. |
| 1888 | d = self.tempdir() |
| 1889 | P(self.base, 'dirA', 'linkX').symlink_to(d) |
| 1890 | P(self.base, str(d), 'linkY').symlink_to(self.parser.join(self.base, 'dirB')) |
| 1891 | p = P(self.base, 'dirA', 'linkX', 'linkY', 'fileB') |
| 1892 | self._check_resolve_absolute(p, P(self.base, 'dirB', 'fileB')) |
| 1893 | # Non-strict |
| 1894 | p = P(self.base, 'dirA', 'linkX', 'linkY', 'foo', 'in', 'spam') |
| 1895 | self._check_resolve_relative(p, P(self.base, 'dirB', 'foo', 'in', 'spam'), |
| 1896 | False) |
| 1897 | p = P(self.base, 'dirA', 'linkX', 'linkY', '..', 'foo', 'in', 'spam') |
| 1898 | if self.cls.parser is not posixpath: |
| 1899 | # In Windows, if linkY points to dirB, 'dirA\linkY\..' |
| 1900 | # resolves to 'dirA' without resolving linkY first. |
| 1901 | self._check_resolve_relative(p, P(d, 'foo', 'in', 'spam'), False) |
| 1902 | else: |
| 1903 | # In Posix, if linkY points to dirB, 'dirA/linkY/..' |
| 1904 | # resolves to 'dirB/..' first before resolving to parent of dirB. |
| 1905 | self._check_resolve_relative(p, P(self.base, 'foo', 'in', 'spam'), False) |
nothing calls this directly
no test coverage detected