Move fake_paths mock to more generic place in rtd_tests.mock.paths
parent
d0d23dee8a
commit
7ba2f7ff2e
|
@ -0,0 +1,18 @@
|
|||
import os
|
||||
import mock
|
||||
|
||||
|
||||
def fake_paths(*paths):
|
||||
"""
|
||||
Returns a context manager that patches ``os.path.exists`` to return
|
||||
``True`` for the given ``paths``.
|
||||
"""
|
||||
|
||||
original_exists = os.path.exists
|
||||
|
||||
def patched_exists(path):
|
||||
if path in paths:
|
||||
return True
|
||||
return original_exists(path)
|
||||
|
||||
return mock.patch.object(os.path, 'exists', patched_exists)
|
|
@ -6,6 +6,7 @@ import mock
|
|||
|
||||
from projects.tasks import build_docs
|
||||
from rtd_tests.factories.projects_factories import ProjectFactory
|
||||
from rtd_tests.mocks.paths import fake_paths
|
||||
from doc_builder.loader import get_builder_class
|
||||
|
||||
|
||||
|
@ -29,22 +30,6 @@ def build_subprocess_side_effect(*args, **kwargs):
|
|||
return subprocess.Popen(*args, **kwargs)
|
||||
|
||||
|
||||
def fake_paths(*paths):
|
||||
"""
|
||||
Returns a context manager that patches ``os.path.exists`` to return
|
||||
``True`` for the given ``paths``.
|
||||
"""
|
||||
|
||||
original_exists = os.path.exists
|
||||
|
||||
def patched_exists(path):
|
||||
if path in paths:
|
||||
return True
|
||||
return original_exists(path)
|
||||
|
||||
return mock.patch.object(os.path, 'exists', patched_exists)
|
||||
|
||||
|
||||
class BuildTests(TestCase):
|
||||
|
||||
@mock.patch('slumber.Resource')
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import os
|
||||
from bamboo_boy.utils import with_canopy
|
||||
import json
|
||||
import mock
|
||||
from django.test import TestCase
|
||||
from builds.constants import LATEST
|
||||
from projects.models import Project
|
||||
from rtd_tests.factories.projects_factories import OneProjectWithTranslationsOneWithout,\
|
||||
ProjectFactory
|
||||
|
|
Loading…
Reference in New Issue