Пример #1
0
def test_decode_encode_path():
    temp_dir = ckan_io.decode_path(tempfile.mkdtemp())
    try:
        filename = u"\xf6\xe4\xfc.txt"
        path = os.path.join(temp_dir, filename)
        with io.open(ckan_io.encode_path(path), u"w", encoding=u"utf-8") as f:
            f.write(u"foo")
        # Force str return type
        filenames = os.listdir(ckan_io.encode_path(temp_dir))
        assert ckan_io.decode_path(filenames[0]) == filename
    finally:
        shutil.rmtree(temp_dir)
Пример #2
0
 def test_decode_encode_path(self):
     temp_dir = ckan_io.decode_path(tempfile.mkdtemp())
     try:
         filename = u'\xf6\xe4\xfc.txt'
         path = os.path.join(temp_dir, filename)
         with io.open(ckan_io.encode_path(path), u'w',
                      encoding=u'utf-8') as f:
             f.write(u'foo')
         # Force str return type
         filenames = os.listdir(ckan_io.encode_path(temp_dir))
         eq_(ckan_io.decode_path(filenames[0]), filename)
     finally:
         shutil.rmtree(temp_dir)
Пример #3
0
 def test_decode_encode_path(self):
     temp_dir = ckan_io.decode_path(tempfile.mkdtemp())
     try:
         filename = u'\xf6\xe4\xfc.txt'
         path = os.path.join(temp_dir, filename)
         with io.open(ckan_io.encode_path(path), u'w',
                      encoding=u'utf-8') as f:
             f.write(u'foo')
         # Force str return type
         filenames = os.listdir(ckan_io.encode_path(temp_dir))
         eq_(ckan_io.decode_path(filenames[0]), filename)
     finally:
         shutil.rmtree(temp_dir)
Пример #4
0
 def test_encode_path_returns_str(self):
     ok_(isinstance(ckan_io.encode_path(u'just_a_unicode'), str))
Пример #5
0
 def test_encode_path_fails_for_str(self):
     ckan_io.encode_path(b'just_a_str')
Пример #6
0
 def test_encode_path_returns_str(self):
     ok_(isinstance(ckan_io.encode_path(u'just_a_unicode'), str))
Пример #7
0
 def test_encode_path_fails_for_str(self):
     ckan_io.encode_path(b'just_a_str')
Пример #8
0
def test_encode_path_returns_str():
    assert isinstance(ckan_io.encode_path(u"just_a_unicode"), str)
Пример #9
0
def test_encode_path_fails_for_str():
    with pytest.raises(TypeError):
        ckan_io.encode_path(b"just_a_str")