From cd596f67886e5023304700ca88adc0c58339e7bf Mon Sep 17 00:00:00 2001 From: Johannes Hoppe Date: Tue, 5 Apr 2016 18:14:20 +0200 Subject: [PATCH] Fixes #146 -- Adds multiprocessing support for sphinx --- configurations/__init__.py | 1 + tests/docs/conf.py | 30 ++++++++++++++++++++++++++++++ tests/docs/index.rst | 2 ++ tests/requirements.txt | 1 + tests/settings/main.py | 1 + tests/test_sphinx.py | 22 ++++++++++++++++++++++ tox.ini | 1 + 7 files changed, 58 insertions(+) create mode 100644 tests/docs/conf.py create mode 100644 tests/docs/index.rst create mode 100644 tests/test_sphinx.py diff --git a/configurations/__init__.py b/configurations/__init__.py index 6256779..64e382a 100644 --- a/configurations/__init__.py +++ b/configurations/__init__.py @@ -32,3 +32,4 @@ def setup(app=None): in your docs' ``conf.py``. """ _setup() + return {'version': __version__, 'parallel_read_safe': True} diff --git a/tests/docs/conf.py b/tests/docs/conf.py new file mode 100644 index 0000000..482b44d --- /dev/null +++ b/tests/docs/conf.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +import os +import sys + +sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir)) + +# setup Django +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.main") +os.environ.setdefault('DJANGO_CONFIGURATION', 'Test') + +extensions = [ + 'configurations', +] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = 'django-configurations' +copyright = '2012-2014, Jannis Leidel and other contributors' + + +version = release = 'test' + +exclude_patterns = ['_build'] + +html_theme = 'default' diff --git a/tests/docs/index.rst b/tests/docs/index.rst new file mode 100644 index 0000000..7193334 --- /dev/null +++ b/tests/docs/index.rst @@ -0,0 +1,2 @@ +Test Documentation +^^^^^^^^^^^^^^^^^^ diff --git a/tests/requirements.txt b/tests/requirements.txt index 5eb9697..39e47b3 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -6,3 +6,4 @@ dj-email-url dj-search-url django-cache-url>=1.0.0 six +Sphinx>=1.4 diff --git a/tests/settings/main.py b/tests/settings/main.py index f9d71d1..6a27de1 100644 --- a/tests/settings/main.py +++ b/tests/settings/main.py @@ -7,6 +7,7 @@ from configurations.values import BooleanValue class Test(Configuration): + BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)) ENV_LOADED = BooleanValue(False) diff --git a/tests/test_sphinx.py b/tests/test_sphinx.py new file mode 100644 index 0000000..5ee61d3 --- /dev/null +++ b/tests/test_sphinx.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +import subprocess +import os + +from django.test import TestCase +from django.conf import settings + + +class ShpinxTests(TestCase): + docs_dir = os.path.join(settings.BASE_DIR, 'docs') + + def test_multiprocessing(self): + output = subprocess.check_output([ + 'sphinx-build', + '-b', + 'html', + '-j 2', + '.', + '_build/html', + ], cwd=self.docs_dir, stderr=subprocess.STDOUT) + self.assertIn(b'waiting for workers', output) + self.assertIn(b'build succeeded.', output) diff --git a/tox.ini b/tox.ini index b70eaf8..3257b42 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,7 @@ skipsdist = True usedevelop = True minversion = 1.8 +whitelist_externals=build-sphinx envlist = flake8-py27, flake8-py35,