def test_deserialize_conversion_success(self): cv = types.Path() result = cv.deserialize(b"/foo") assert result == "/foo" assert isinstance(result, types._ExpandedPath) assert isinstance(result, str)
def test_serialize_unicode_string(self): value = types.Path() self.assertRaises(ValueError, value.serialize, 'æøå')
def test_serialize_plain_string(self): value = types.Path() self.assertEqual('path', value.serialize(b'path'))
def test_serialize_uses_original(self): path = types.ExpandedPath(b'original_path', b'expanded_path') value = types.Path() self.assertEqual('expanded_path', path) self.assertEqual('original_path', value.serialize(path))
def test_deserialize_respects_optional(self): value = types.Path(optional=True) self.assertIsNone(value.deserialize(b'')) self.assertIsNone(value.deserialize(b' '))
def test_deserialize_enforces_required(self): value = types.Path() self.assertRaises(ValueError, value.deserialize, b'')
def test_deserialize_conversion_success(self): result = types.Path().deserialize(b'/foo') self.assertEqual('/foo', result) self.assertIsInstance(result, types.ExpandedPath) self.assertIsInstance(result, bytes)
def test_serialize_supports_unicode_string(self): cv = types.Path() assert cv.serialize("æøå") == "æøå"
def test_serialize_plain_string(self): cv = types.Path() assert cv.serialize(b"path") == "path"
def test_serialize_uses_original(self): cv = types.Path() path = types._ExpandedPath("original_path", "expanded_path") assert cv.serialize(path) == "original_path"
def test_deserialize_respects_optional(self): cv = types.Path(optional=True) assert cv.deserialize(b"") is None assert cv.deserialize(b" ") is None
def test_deserialize_enforces_required(self): cv = types.Path() with pytest.raises(ValueError): cv.deserialize(b"")
def test_serialize_unicode_string(self): value = types.Path() expected = 'æøå'.encode(sys.getfilesystemencoding()) result = value.serialize('æøå') self.assertEqual(expected, result) self.assertIsInstance(result, bytes)