def test_str(self): """Tests getting string representations (repr/bytes/unicode).""" utf = PosixPath(b'/tmp/r\xC3\xA9mi') nonutf = PosixPath(b'/tmp/r\xE9mi') # repr() self.assertEqual(repr(utf), "PosixPath(b'/tmp/r\\xc3\\xa9mi')") self.assertEqual(repr(nonutf), "PosixPath(b'/tmp/r\\xe9mi')") # bytes() self.assertEqual(bytes(utf), b'/tmp/r\xC3\xA9mi') self.assertEqual(bytes(nonutf), b'/tmp/r\xE9mi') # unicode() self.assertEqual(unicode(utf), u'/tmp/r\xE9mi') self.assertEqual(unicode(nonutf), u'/tmp/r\uFFFDmi')
def test_str(self): """Tests getting string representations (repr/bytes/unicode).""" latin = WindowsPath(u'C:\\r\xE9mi') nonlatin = WindowsPath(u'C:\\you like\u203D.txt') # repr() self.assertEqual(repr(latin), "WindowsPath(u'C:\\\\r\\xe9mi')") self.assertEqual(repr(nonlatin), "WindowsPath(u'C:\\\\you like\\u203d.txt')") # bytes() self.assertEqual(bytes(latin), b'C:\\r\xe9mi') self.assertEqual(bytes(nonlatin), b'C:\\you like?.txt') # unicode() self.assertEqual(unicode(latin), u'C:\\r\xe9mi') self.assertEqual(unicode(nonlatin), u'C:\\you like\u203d.txt')