From 43e48f8542ffcdfc14a00641fab9c94f5ef2f33b Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 4 Mar 2018 16:36:28 -0500 Subject: [PATCH] clean things up Signed-off-by: Kenneth Reitz --- run-tests.sh | 7 +++++-- tests/test_pipenv.py | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index fb374372..e61fb3cb 100644 --- a/run-tests.sh +++ b/run-tests.sh @@ -11,7 +11,10 @@ fi RAM_DISK="/media/ramdisk" export RAM_DISK -sudo mkdir -p "$RAM_DISK" -sudo mount -t tmpfs -o size=2048M tmpfs "$RAM_DISK" +if [[ "$CI" ]]; then + sudo mkdir -p "$RAM_DISK" + sudo mount -t tmpfs -o size=2048M tmpfs "$RAM_DISK" +fi + pytest -n 8 tests -m "$TEST_SUITE" \ No newline at end of file diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 8efb4c19..c4b22693 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -27,14 +27,6 @@ os.environ['PIPENV_DONT_USE_PYENV'] = '1' os.environ['PIPENV_IGNORE_VIRTUALENVS'] = '1' os.environ['PYPI_VENDOR_DIR'] = os.path.sep.join([os.path.dirname(__file__), 'pypi']) -from flask import Flask - -class PYPI(object): - """docstring for PYPI""" - def __init__(self, packages=None): - super(PYPI, self).__init__() - self.packages = packages or [] - @pytest.fixture(scope='module') def pip_src_dir(request): @@ -48,13 +40,23 @@ def pip_src_dir(request): return request +def ram_disk_or_tempdir(): + import uuid + if 'RAM_DISK' in os.environ: + name = uuid.uuid4().hex + dir_name = os.path.sep.join([os.environ['RAM_DISK'], name]) + os.mkdir(dir_name) + return dir_name + else: + return TemporaryDirectory(suffix='project', prefix='pipenv') + class PipenvInstance(): """An instance of a Pipenv Project...""" def __init__(self, pypi=None, pipfile=True, chdir=False): self.pypi = pypi self.original_umask = os.umask(0o007) self.original_dir = os.path.abspath(os.curdir) - self._path = TemporaryDirectory(suffix='project', prefix='pipenv') + self._path = ram_disk_or_tempdir() self.path = self._path.name # set file creation perms self.pipfile_path = None