def media_directories(): dirs = [settings.STATIC_ROOT] for repo_dir in optionalapps.get_repository_paths(): repo_media_dir = os.path.join(repo_dir, 'media') if os.path.exists(repo_media_dir): dirs.append(repo_media_dir) return dirs
def setup_path(): root_dir = os.path.abspath(os.path.dirname(__file__)) sys.path.insert(0, os.path.join(root_dir, 'apps')) sys.path.insert(0, os.path.join(root_dir, 'libs')) # add paths from optional repositories import optionalapps sys.path.extend(optionalapps.get_repository_paths())
def find_python_files(self): dirs_to_search = [] dirs_to_search.append(os.path.join(settings.PROJECT_ROOT, 'apps')) dirs_to_search.extend(optionalapps.get_repository_paths()) for dir_path in dirs_to_search: for path in self.find_files(dir_path, '.py'): yield path
def find_javascript_files(self): dirs_to_search = [os.path.join(settings.PROJECT_ROOT, 'media/src/js/')] for repo_dir in optionalapps.get_repository_paths(): js_dir = os.path.join(repo_dir, 'media/js') if os.path.isdir(js_dir): dirs_to_search.append(js_dir) for dir_path in dirs_to_search: for path in self.find_files(dir_path, '.js'): yield path
def wantDirectory(self, dirname): if dirname in self.directories_to_skip: return False if not self.include_webdriver_tests and 'webdriver' in dirname: return False if dirname == os.path.join(settings.PROJECT_ROOT, 'apps'): # force the tests from the apps directory to be loaded, even # though it's not a package return True if dirname in optionalapps.get_repository_paths(): # same thing for optional app repos return True return None
def wantDirectory(self, dirname): if dirname in self.directories_to_skip: return False if not self.include_webdriver_tests and 'webdriver' in dirname: return False if os.path.basename(dirname) in ('api', 'vimeoapi', 'enterpriseapi'): # Need to exclude these for now until we upgrade django return False if dirname == os.path.join(settings.PROJECT_ROOT, 'apps'): # force the tests from the apps directory to be loaded, even # though it's not a package return True if dirname in optionalapps.get_repository_paths(): # same thing for optional app repos return True return None
def setup_test_directories(testdir): """ Merge together the various test/ directories We allow each subrepository to create its own test directory, which then get merged together to create a virtual test package with some magic from tests/__init__.py. However, this doesn't work with py.test, since it expects to be able to walk through the filesystem paths to find files like conftest.py. To work around this, symlink all the actual files into an actual directory """ setup_test_links(optionalapps.project_root, testdir) for repo_path in optionalapps.get_repository_paths(): setup_test_links(repo_path, testdir) # create the __init__.py file with open('__init__.py', 'w'): pass # We now have a bunch of potential packages named "tests". Mess with the # path/module registry to ensure that it's the one we just created the # symlinks with. sys.path.insert(0, '') import tests
import os import optionalapps __path__.extend( os.path.join(p, 'guitests') for p in optionalapps.get_repository_paths())