Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python35
/
lib64
/
python3.5
/
site-packages
/
scipy
/
_lib
/
tests
/
File Content:
test_tmpdirs.py
""" Test tmpdirs module """ from __future__ import division, print_function, absolute_import from os import getcwd from os.path import realpath, abspath, dirname, isfile, join as pjoin, exists from scipy._lib._tmpdirs import tempdir, in_tempdir, in_dir from numpy.testing import run_module_suite, assert_, assert_equal MY_PATH = abspath(__file__) MY_DIR = dirname(MY_PATH) def test_tempdir(): with tempdir() as tmpdir: fname = pjoin(tmpdir, 'example_file.txt') with open(fname, 'wt') as fobj: fobj.write('a string\\n') assert_(not exists(tmpdir)) def test_in_tempdir(): my_cwd = getcwd() with in_tempdir() as tmpdir: with open('test.txt', 'wt') as f: f.write('some text') assert_(isfile('test.txt')) assert_(isfile(pjoin(tmpdir, 'test.txt'))) assert_(not exists(tmpdir)) assert_equal(getcwd(), my_cwd) def test_given_directory(): # Test InGivenDirectory cwd = getcwd() with in_dir() as tmpdir: assert_equal(tmpdir, abspath(cwd)) assert_equal(tmpdir, abspath(getcwd())) with in_dir(MY_DIR) as tmpdir: assert_equal(tmpdir, MY_DIR) assert_equal(realpath(MY_DIR), realpath(abspath(getcwd()))) # We were deleting the given directory! Check not so now. assert_(isfile(MY_PATH)) if __name__ == "__main__": run_module_suite()
Submit
FILE
FOLDER
Name
Size
Permission
Action
__pycache__
---
0755
test__gcutils.py
2804 bytes
0644
test__threadsafety.py
778 bytes
0644
test__util.py
1450 bytes
0644
test__version.py
2027 bytes
0644
test_tmpdirs.py
1379 bytes
0644
N4ST4R_ID | Naxtarrr