<s> import os <EOL> import py <EOL> import pytest <EOL> import qisys . sh <EOL> from qidoc . test . conftest import find_link <EOL> import qidoc . builder <EOL> def test_no_templates ( doc_worktree ) : <EOL> foo_sphinx = doc_worktree . create_sphinx_project ( "<STR_LIT:foo>" ) <EOL> foo_path = py . path . local ( foo_sphinx . path ) <EOL> conf_py = foo_path . join ( "<STR_LIT:source>" , "<STR_LIT>" ) . ensure ( file = True ) <EOL> settings = """<STR_LIT>""" <EOL> conf_py . write ( settings ) <EOL> foo_sphinx . configure ( ) <EOL> conf_py = foo_path . join ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> assert settings in conf_py . read ( ) <EOL> def test_sets_project_name_when_not_defined ( doc_worktree ) : <EOL> foo_sphinx = doc_worktree . create_sphinx_project ( "<STR_LIT:foo>" ) <EOL> foo_path = py . path . local ( foo_sphinx . path ) <EOL> conf_py = foo_path . join ( "<STR_LIT:source>" , "<STR_LIT>" ) . ensure ( file = True ) <EOL> foo_sphinx . configure ( ) <EOL> conf_py = foo_path . join ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> assert '<STR_LIT>' in conf_py . read ( ) <EOL> def test_version_from_conf_py ( doc_worktree ) : <EOL> foo_sphinx = doc_worktree . create_sphinx_project ( "<STR_LIT:foo>" ) <EOL> foo_path = py . path . local ( foo_sphinx . path ) <EOL> conf_py = foo_path . join ( "<STR_LIT:source>" , "<STR_LIT>" ) . ensure ( file = True ) <EOL> conf_py . write ( '<STR_LIT>' ) <EOL> foo_sphinx . configure ( version = "<STR_LIT>" ) <EOL> conf_py = foo_path . join ( "<STR_LIT>" , "<STR_LIT>" ) . read ( ) <EOL> assert '<STR_LIT>' in conf_py <EOL> def test_read_version_from_qiproject ( doc_worktree ) : <EOL> foo_sphinx = doc_worktree . create_sphinx_project ( "<STR_LIT:foo>" ) <EOL> foo_path = py . path . local ( foo_sphinx . path ) <EOL> conf_py = foo_path . join ( "<STR_LIT:source>" , "<STR_LIT>" ) . ensure ( file = True ) <EOL> conf_py . write ( '<STR_LIT>' ) <EOL> foo_sphinx . version = "<STR_LIT>" <EOL> foo_sphinx . configure ( ) <EOL> conf_py = foo_path . join ( "<STR_LIT>" , "<STR_LIT>" ) . read ( ) <EOL> assert '<STR_LIT>' in conf_py <EOL> def test_handles_dunder_file ( doc_worktree ) : <EOL> foo_sphinx = doc_worktree . create_sphinx_project ( "<STR_LIT:foo>" ) <EOL> foo_path = py . path . local ( foo_sphinx . path ) <EOL> conf_py_path = foo_path . join ( "<STR_LIT:source>" , "<STR_LIT>" ) . ensure ( file = True ) <EOL> conf_py_path . write ( "<STR_LIT>" ) <EOL> foo_sphinx . configure ( version = "<STR_LIT>" ) <EOL> conf_py = foo_path . join ( "<STR_LIT>" , "<STR_LIT>" ) . read ( ) <EOL> new_conf = dict ( ) <EOL> exec ( conf_py , new_conf ) <EOL> assert new_conf [ "<STR_LIT>" ] == conf_py_path . strpath <EOL> def test_with_template ( doc_worktree ) : <EOL> foo_sphinx = doc_worktree . create_sphinx_project ( "<STR_LIT:foo>" ) <EOL> doc_worktree . add_templates ( ) <EOL> foo_path = py . path . local ( foo_sphinx . path ) <EOL> conf_py = foo_path . join ( "<STR_LIT:source>" , "<STR_LIT>" ) . ensure ( file = True ) <EOL> settings = """<STR_LIT>""" <EOL> conf_py . write ( settings ) <EOL> foo_sphinx . configure ( version = "<STR_LIT>" ) <EOL> conf_py = foo_path . join ( "<STR_LIT>" , "<STR_LIT>" ) . read ( ) <EOL> conf_dict = dict ( ) <EOL> assert "<STR_LIT>" in conf_py <EOL> exec ( conf_py , conf_dict ) <EOL> assert conf_dict [ "<STR_LIT:version>" ] == "<STR_LIT>" <EOL> expected = doc_worktree . template_project . themes_path <EOL> assert conf_dict [ "<STR_LIT>" ] == [ expected ] <EOL> def test_build ( doc_worktree ) : <EOL> doc_worktree . add_test_project ( "<STR_LIT>" ) <EOL> qi_sphinx = doc_worktree . get_doc_project ( "<STR_LIT>" , raises = True ) <EOL> qi_sphinx . configure ( ) <EOL> qi_sphinx . build ( ) <EOL> assert os . path . exists ( qi_sphinx . index_html ) <EOL> def test_prebuild ( doc_worktree ) : <EOL> doc_worktree . add_test_project ( "<STR_LIT>" ) <EOL> qi_sphinx = doc_worktree . get_doc_project ( "<STR_LIT>" ) <EOL> qi_sphinx . configure ( ) <EOL> qi_sphinx . build ( werror = True ) <EOL> def test_examples ( doc_worktree , tmpdir ) : <EOL> examples_proj = doc_worktree . add_test_project ( "<STR_LIT>" ) <EOL> examples_proj . configure ( ) <EOL> examples_proj . build ( werror = True ) <EOL> dest = tmpdir . mkdir ( "<STR_LIT>" ) <EOL> examples_proj . install ( dest . strpath ) <EOL> assert dest . join ( "<STR_LIT>" , "<STR_LIT:a>" , "<STR_LIT>" ) . check ( file = True ) <EOL> def test_doxydeps ( doc_worktree , tmpdir ) : <EOL> sphinx_proj = doc_worktree . add_test_project ( "<STR_LIT>" ) <EOL> doxy_proj = doc_worktree . add_test_project ( "<STR_LIT>" ) <EOL> doc_builder = qidoc . builder . DocBuilder ( doc_worktree , "<STR_LIT>" ) <EOL> doc_builder . configure ( ) <EOL> doc_builder . build ( ) <EOL> link = find_link ( sphinx_proj . index_html , "<STR_LIT>" ) <EOL> assert os . path . exists ( link ) <EOL> doc_builder . install ( tmpdir . strpath ) <EOL> link = find_link ( tmpdir . join ( "<STR_LIT>" ) . strpath , "<STR_LIT>" ) <EOL> assert not os . path . isabs ( link ) <EOL> assert tmpdir . join ( link ) . check ( file = True ) <EOL> def test_install_twice ( doc_worktree , tmpdir ) : <EOL> world_proj = doc_worktree . add_test_project ( "<STR_LIT>" ) <EOL> hello_proj = doc_worktree . add_test_project ( "<STR_LIT:hello>" ) <EOL> doc_builder = qidoc . builder . DocBuilder ( doc_worktree , "<STR_LIT:hello>" ) <EOL> doc_builder . werror = True <EOL> dest1 = tmpdir . join ( "<STR_LIT>" ) <EOL> doc_builder . install ( dest1 . strpath ) <EOL> assert dest1 . join ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) . check ( file = True ) <EOL> dest2 = tmpdir . join ( "<STR_LIT>" ) <EOL> doc_builder . install ( dest2 . strpath ) <EOL> assert dest2 . join ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) . check ( file = True ) <EOL> @ pytest . mark . skipif ( "<STR_LIT:True>" ) <EOL> def test_intersphinx ( doc_worktree , tmpdir ) : <EOL> world_proj = doc_worktree . add_test_project ( "<STR_LIT>" ) <EOL> hello_proj = doc_worktree . add_test_project ( "<STR_LIT:hello>" ) <EOL> doc_builder = qidoc . builder . DocBuilder ( doc_worktree , "<STR_LIT:hello>" ) <EOL> doc_builder . werror = True <EOL> doc_builder . configure ( ) <EOL> doc_builder . build ( ) <EOL> link = find_link ( hello_proj . index_html , "<STR_LIT>" ) <EOL> assert os . path . exists ( link ) <EOL> doc_builder . install ( tmpdir . strpath ) <EOL> link = find_link ( tmpdir . join ( "<STR_LIT>" ) . strpath , "<STR_LIT>" ) <EOL> assert not os . path . isabs ( link ) <EOL> assert tmpdir . join ( link ) . check ( file = True ) <EOL> def test_spellcheck ( doc_worktree , record_messages ) : <EOL> spell_proj = doc_worktree . add_test_project ( "<STR_LIT>" ) <EOL> doc_builder = qidoc . builder . DocBuilder ( doc_worktree , "<STR_LIT>" ) <EOL> doc_builder . spellcheck = True <EOL> doc_builder . configure ( ) <EOL> with pytest . raises ( qidoc . sphinx_project . SphinxBuildError ) : <EOL> doc_builder . build ( ) <EOL> assert record_messages . find ( "<STR_LIT>" ) <EOL> index_rst = os . path . join ( spell_proj . path , "<STR_LIT:source>" , "<STR_LIT>" ) <EOL> with open ( index_rst , "<STR_LIT:r>" ) as fp : <EOL> contents = fp . read ( ) <EOL> contents = contents . replace ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> with open ( index_rst , "<STR_LIT:w>" ) as fp : <EOL> fp . write ( contents ) <EOL> qisys . sh . rm ( spell_proj . build_dir ) <EOL> doc_builder . configure ( ) <EOL> doc_builder . build ( ) <EOL> def test_intl_update ( doc_worktree ) : <EOL> translateme_proj = doc_worktree . add_test_project ( "<STR_LIT>" ) <EOL> assert translateme_proj . linguas == [ "<STR_LIT>" ] <EOL> translateme_proj . configure ( ) <EOL> translateme_proj . intl_update ( ) <EOL> pot_expected = os . path . join ( translateme_proj . source_dir , "<STR_LIT>" , "<STR_LIT>" ) <EOL> assert os . path . exists ( pot_expected ) <EOL> po_expected = os . path . join ( translateme_proj . source_dir , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> assert os . path . exists ( po_expected ) <EOL> def test_intl_build ( doc_worktree ) : <EOL> translateme_proj = doc_worktree . add_test_project ( "<STR_LIT>" ) <EOL> translateme_proj . configure ( ) <EOL> translateme_proj . intl_update ( ) <EOL> translateme_proj . intl_build ( "<STR_LIT>" ) <EOL> mo_expected = os . path . join ( translateme_proj . source_dir , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> assert os . path . exists ( mo_expected ) </s>
