summaryrefslogtreecommitdiff
path: root/setuptools/tests
diff options
context:
space:
mode:
authorMelissa Li <li.melissa.kun@gmail.com>2021-02-18 23:02:29 -0500
committerMelissa Li <li.melissa.kun@gmail.com>2021-02-19 17:11:54 -0500
commit37a6284c9fcd71a3d4b2fe5dbc802fcf5cbe0786 (patch)
treee85e4323f7598363ed6c0c1fcaee49c5e6919f64 /setuptools/tests
parente1ffc2abbae4f2aa78dd09ee9827d754b7702b7b (diff)
downloadpython-setuptools-git-37a6284c9fcd71a3d4b2fe5dbc802fcf5cbe0786.tar.gz
Fix sphinx upload_docs
Diffstat (limited to 'setuptools/tests')
-rw-r--r--setuptools/tests/requirements.txt1
-rw-r--r--setuptools/tests/test_sphinx_upload_docs.py42
2 files changed, 43 insertions, 0 deletions
diff --git a/setuptools/tests/requirements.txt b/setuptools/tests/requirements.txt
index d0d07f70..b2d84a94 100644
--- a/setuptools/tests/requirements.txt
+++ b/setuptools/tests/requirements.txt
@@ -11,3 +11,4 @@ paver; python_version>="3.6"
futures; python_version=="2.7"
pip>=19.1 # For proper file:// URLs support.
jaraco.envs
+sphinx
diff --git a/setuptools/tests/test_sphinx_upload_docs.py b/setuptools/tests/test_sphinx_upload_docs.py
new file mode 100644
index 00000000..4287b00e
--- /dev/null
+++ b/setuptools/tests/test_sphinx_upload_docs.py
@@ -0,0 +1,42 @@
+import pytest
+import os
+
+from setuptools.command.upload_docs import upload_docs
+from setuptools.dist import Distribution
+
+
+@pytest.fixture
+def sphinx_doc_sample_project(tmpdir_cwd):
+ # setup.py
+ with open('setup.py', 'wt') as f:
+ f.write('from setuptools import setup; setup()\n')
+
+ os.makedirs('build/docs')
+
+ # A test conf.py for Sphinx
+ with open('build/docs/conf.py', 'w') as f:
+ f.write("project = 'test'")
+
+ # A test index.rst for Sphinx
+ with open('build/docs/index.rst', 'w') as f:
+ f.write(".. toctree::\
+ :maxdepth: 2\
+ :caption: Contents:")
+
+
+@pytest.mark.usefixtures('sphinx_doc_sample_project')
+@pytest.mark.usefixtures('user_override')
+class TestSphinxUploadDocs:
+ def test_sphinx_doc(self):
+ params = dict(
+ name='foo',
+ packages=['test'],
+ )
+ dist = Distribution(params)
+
+ cmd = upload_docs(dist)
+
+ cmd.initialize_options()
+ assert cmd.upload_dir is None
+ assert cmd.has_sphinx() is True
+ cmd.finalize_options()