Skip to content

Commit

Permalink
Use path builder in upload_docs tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 20, 2021
1 parent d31f7f0 commit fc55ecf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 34 deletions.
27 changes: 12 additions & 15 deletions setuptools/tests/test_sphinx_upload_docs.py
@@ -1,27 +1,24 @@
import pytest
import os

from jaraco import path

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::\
path.build({
'setup.py': 'from setuptools import setup; setup()',
'build': {
'docs': {
'conf.py': 'project="test"',
'index.rst': ".. toctree::\
:maxdepth: 2\
:caption: Contents:")
:caption: Contents:",
},
},
})


@pytest.mark.usefixtures('sphinx_doc_sample_project')
Expand Down
31 changes: 12 additions & 19 deletions setuptools/tests/test_upload_docs.py
Expand Up @@ -3,35 +3,28 @@
import contextlib

import pytest
from jaraco import path

from setuptools.command.upload_docs import upload_docs
from setuptools.dist import Distribution

from .textwrap import DALS
from . import contexts

SETUP_PY = DALS(
"""
from setuptools import setup
setup(name='foo')
""")


@pytest.fixture
def sample_project(tmpdir_cwd):
# setup.py
with open('setup.py', 'wt') as f:
f.write(SETUP_PY)

os.mkdir('build')

# A test document.
with open('build/index.html', 'w') as f:
f.write("Hello world.")

# An empty folder.
os.mkdir('build/empty')
path.build({
'setup.py': DALS("""
from setuptools import setup
setup(name='foo')
"""),
'build': {
'index.html': 'Hello world.',
'empty': {},
}
})


@pytest.mark.usefixtures('sample_project')
Expand Down

0 comments on commit fc55ecf

Please sign in to comment.