summaryrefslogtreecommitdiff
path: root/setuptools/tests/test_sphinx_upload_docs.py
blob: 4287b00e4ee234c3be4a06c6aa9302348067e9ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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()