File: test_errors.py

package info (click to toggle)
python-fs 0.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,452 kB
  • ctags: 2,991
  • sloc: python: 20,659; makefile: 5
file content (32 lines) | stat: -rw-r--r-- 819 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- encoding: utf-8 -*-
"""

  fs.tests.test_errors:  testcases for the fs error classes functions

"""


import unittest
import fs.tests
from fs.errors import *
import pickle

from fs.path import *

class TestErrorPickling(unittest.TestCase):

    def test_pickling(self):
        def assert_dump_load(e):
            e2 = pickle.loads(pickle.dumps(e))
            self.assertEqual(e.__dict__,e2.__dict__)
        assert_dump_load(FSError())
        assert_dump_load(PathError("/some/path"))
        assert_dump_load(ResourceNotFoundError("/some/other/path"))
        assert_dump_load(UnsupportedError("makepony"))


class TestFSError(unittest.TestCase):

    def test_unicode_representation_of_error_with_non_ascii_characters(self):
        path_error = PathError('/Shïrê/Frødø')
        _ = unicode(path_error)