def test_suffix(self): p1 = RemotePath(self._connect(), "/some/long/path/to/file.txt") p2 = RemotePath(self._connect(), "file.tar.gz") assert p1.suffix == ".txt" assert p1.suffixes == [".txt"] assert p2.suffix == ".gz" assert p2.suffixes == [".tar",".gz"] strassert(p1.with_suffix(".tar.gz"), RemotePath(self._connect(), "/some/long/path/to/file.tar.gz")) strassert(p2.with_suffix(".other"), RemotePath(self._connect(), "file.tar.other")) strassert(p2.with_suffix(".other", 2), RemotePath(self._connect(), "file.other")) strassert(p2.with_suffix(".other", 0), RemotePath(self._connect(), "file.tar.gz.other")) strassert(p2.with_suffix(".other", None), RemotePath(self._connect(), "file.other"))
def test_suffix(self): p1 = RemotePath(self._connect(), "/some/long/path/to/file.txt") p2 = RemotePath(self._connect(), "file.tar.gz") strcmp = lambda a,b: self.assertEqual(str(a),str(b)) self.assertEqual(p1.suffix, ".txt") self.assertEqual(p1.suffixes, [".txt"]) self.assertEqual(p2.suffix, ".gz") self.assertEqual(p2.suffixes, [".tar",".gz"]) strcmp(p1.with_suffix(".tar.gz"), RemotePath(self._connect(), "/some/long/path/to/file.tar.gz")) strcmp(p2.with_suffix(".other"), RemotePath(self._connect(), "file.tar.other")) strcmp(p2.with_suffix(".other", 2), RemotePath(self._connect(), "file.other")) strcmp(p2.with_suffix(".other", 0), RemotePath(self._connect(), "file.tar.gz.other")) strcmp(p2.with_suffix(".other", None), RemotePath(self._connect(), "file.other"))
def test_suffix(self): p1 = RemotePath(self._connect(), "/some/long/path/to/file.txt") p2 = RemotePath(self._connect(), "file.tar.gz") strcmp = lambda a, b: self.assertEqual(str(a), str(b)) self.assertEqual(p1.suffix, ".txt") self.assertEqual(p1.suffixes, [".txt"]) self.assertEqual(p2.suffix, ".gz") self.assertEqual(p2.suffixes, [".tar", ".gz"]) strcmp(p1.with_suffix(".tar.gz"), RemotePath(self._connect(), "/some/long/path/to/file.tar.gz")) strcmp(p2.with_suffix(".other"), RemotePath(self._connect(), "file.tar.other")) strcmp(p2.with_suffix(".other", 2), RemotePath(self._connect(), "file.other")) strcmp(p2.with_suffix(".other", 0), RemotePath(self._connect(), "file.tar.gz.other")) strcmp(p2.with_suffix(".other", None), RemotePath(self._connect(), "file.other"))