Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
50 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
from contextlib import contextmanager | ||
from tempfile import mkdtemp | ||
import os | ||
import random | ||
import shutil | ||
import stat | ||
|
||
|
||
@contextmanager | ||
def temp_dir(): | ||
name = make_temp_dir() | ||
yield name | ||
shutil.rmtree(name) | ||
|
||
def make_temp_dir(): | ||
if os.path.exists('/dev/shm/'): | ||
if os.stat('/dev/shm').st_mode & stat.S_IWGRP: | ||
dirname = 'django-cms-tests-%s' % random.randint(1,1000000) | ||
path = os.path.join('/dev/shm', dirname) | ||
while os.path.exists(path): | ||
dirname = 'django-cms-tests-%s' % random.randint(1,1000000) | ||
path = os.path.join('/dev/shm', dirname) | ||
os.mkdir(path) | ||
return path | ||
return mkdtemp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters