Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
 def test_serialize_unicode_string(self):
     value = types.Path()
     self.assertRaises(ValueError, value.serialize, 'æøå')
Exemplo n.º 3
0
 def test_serialize_plain_string(self):
     value = types.Path()
     self.assertEqual('path', value.serialize(b'path'))
Exemplo n.º 4
0
 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))
Exemplo n.º 5
0
 def test_deserialize_respects_optional(self):
     value = types.Path(optional=True)
     self.assertIsNone(value.deserialize(b''))
     self.assertIsNone(value.deserialize(b' '))
Exemplo n.º 6
0
 def test_deserialize_enforces_required(self):
     value = types.Path()
     self.assertRaises(ValueError, value.deserialize, b'')
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
    def test_serialize_supports_unicode_string(self):
        cv = types.Path()

        assert cv.serialize("æøå") == "æøå"
Exemplo n.º 9
0
    def test_serialize_plain_string(self):
        cv = types.Path()

        assert cv.serialize(b"path") == "path"
Exemplo n.º 10
0
    def test_serialize_uses_original(self):
        cv = types.Path()
        path = types._ExpandedPath("original_path", "expanded_path")

        assert cv.serialize(path) == "original_path"
Exemplo n.º 11
0
    def test_deserialize_respects_optional(self):
        cv = types.Path(optional=True)

        assert cv.deserialize(b"") is None
        assert cv.deserialize(b" ") is None
Exemplo n.º 12
0
    def test_deserialize_enforces_required(self):
        cv = types.Path()

        with pytest.raises(ValueError):
            cv.deserialize(b"")
Exemplo n.º 13
0
 def test_serialize_unicode_string(self):
     value = types.Path()
     expected = 'æøå'.encode(sys.getfilesystemencoding())
     result = value.serialize('æøå')
     self.assertEqual(expected, result)
     self.assertIsInstance(result, bytes)