cms.test_utils.tmpdir: 21 total statements, 0.0% covered

Generated: Wed 2013-03-13 10:33 CET

Source file: /media/Envs/Envs/filer-gallery/lib/python2.7/site-packages/cms/test_utils/tmpdir.py

Stats: 0 executed, 15 missed, 6 excluded, 5 ignored

  1. # -*- coding: utf-8 -*-
  2. from contextlib import contextmanager
  3. from tempfile import mkdtemp
  4. import os
  5. import random
  6. import shutil
  7. import stat
  8. @contextmanager
  9. def temp_dir():
  10. name = make_temp_dir()
  11. yield name
  12. shutil.rmtree(name)
  13. def make_temp_dir():
  14. if os.path.exists('/dev/shm/'):
  15. if os.stat('/dev/shm').st_mode & stat.S_IWGRP:
  16. dirname = 'django-cms-tests-%s' % random.randint(1,1000000)
  17. path = os.path.join('/dev/shm', dirname)
  18. while os.path.exists(path):
  19. dirname = 'django-cms-tests-%s' % random.randint(1,1000000)
  20. path = os.path.join('/dev/shm', dirname)
  21. os.mkdir(path)
  22. return path
  23. return mkdtemp()