-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
test_sphinx_upload_docs.py
41 lines (31 loc) · 1.02 KB
/
test_sphinx_upload_docs.py
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
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')
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()