File: test_io.py

package info (click to toggle)
ubelt 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,180 kB
  • sloc: python: 15,487; sh: 807; makefile: 24
file content (27 lines) | stat: -rw-r--r-- 803 bytes parent folder | download | duplicates (3)
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
from __future__ import unicode_literals
from os.path import os


def test_touch():
    import ubelt as ub
    dpath = ub.Path.appdir('ubelt', 'tests').ensuredir()
    fpath = dpath / 'touch_file'
    assert not fpath.exists()
    ub.touch(fpath, verbose=True)
    assert fpath.exists()
    os.unlink(fpath)


def test_readwrite():
    import pytest
    import ubelt as ub
    dpath = ub.Path.appdir('ubelt', 'tests').ensuredir()
    fpath = dpath / 'testwrite.txt'
    if fpath.exists():
        os.remove(fpath)
    to_write = 'utf-8 symbols Δ, Й, ק, م, ๗, あ, 叶, 葉, and 말.'
    with pytest.warns(DeprecationWarning):
        ub.writeto(fpath, to_write, verbose=True)
    with pytest.warns(DeprecationWarning):
        read_ = ub.readfrom(fpath, verbose=True)
    assert read_ == to_write