def test_builders_config(self): build_doc = packaging.LocalBuildDoc(self.distr) build_doc.finalize_options() self.assertEqual(1, len(build_doc.builders)) self.assertIn('html', build_doc.builders) build_doc = packaging.LocalBuildDoc(self.distr) build_doc.builders = '' build_doc.finalize_options() self.assertEqual('', build_doc.builders) build_doc = packaging.LocalBuildDoc(self.distr) build_doc.builders = 'man' build_doc.finalize_options() self.assertEqual(1, len(build_doc.builders)) self.assertIn('man', build_doc.builders) build_doc = packaging.LocalBuildDoc(self.distr) build_doc.builders = 'html,man,doctest' build_doc.finalize_options() self.assertIn('html', build_doc.builders) self.assertIn('man', build_doc.builders) self.assertIn('doctest', build_doc.builders)
def test_builders_config(self): if self.has_opt: self.distr.command_options["pbr"] = { "autodoc_index_modules": ('setup.cfg', self.autodoc) } build_doc = packaging.LocalBuildDoc(self.distr) build_doc.finalize_options() self.assertEqual(2, len(build_doc.builders)) self.assertIn('html', build_doc.builders) self.assertIn('man', build_doc.builders) build_doc = packaging.LocalBuildDoc(self.distr) build_doc.builders = '' build_doc.finalize_options() self.assertEqual('', build_doc.builders) build_doc = packaging.LocalBuildDoc(self.distr) build_doc.builders = 'man' build_doc.finalize_options() self.assertEqual(1, len(build_doc.builders)) self.assertIn('man', build_doc.builders) build_doc = packaging.LocalBuildDoc(self.distr) build_doc.builders = 'html,man,doctest' build_doc.finalize_options() self.assertIn('html', build_doc.builders) self.assertIn('man', build_doc.builders) self.assertIn('doctest', build_doc.builders)
def test_build_doc(self): if self.has_opt: self.distr.command_options["pbr"] = { "autodoc_index_modules": ('setup.cfg', self.autodoc)} build_doc = packaging.LocalBuildDoc(self.distr) build_doc.run() self.assertTrue( os.path.exists("api/autoindex.rst") == self.has_autodoc) self.assertTrue( os.path.exists( "api/fake_package.fake_module.rst") == self.has_autodoc)
def test_cmd_builder_override_multiple_builders(self): if self.has_opt: self.distr.command_options["pbr"] = { "autodoc_index_modules": ('setup.cfg', self.autodoc) } self.distr.command_options["build_sphinx"]["builder"] = ( "command line", "builder1,builder2") build_doc = packaging.LocalBuildDoc(self.distr) build_doc.finalize_options() self.assertEqual(["builder1", "builder2"], build_doc.builders)
def test_default_api_build_dir(self): build_doc = packaging.LocalBuildDoc(self.distr) build_doc.run() print('PBR OPTIONS:', self.pbr_options) print('DISTR OPTIONS:', self.distr.command_options) self.assertTrue(os.path.exists("api/autoindex.rst")) self.assertTrue(os.path.exists("api/fake_package.fake_module.rst")) self.assertTrue( os.path.exists("api/fake_package.fake_private_module.rst")) self.assertTrue( os.path.exists( "api/fake_package.another_fake_module_for_testing.rst"))
def test_build_doc(self): build_doc = packaging.LocalBuildDoc(self.distr) build_doc.run() self.assertTrue( os.path.exists("api/autoindex.rst") == self.has_autodoc) self.assertTrue( os.path.exists("api/fake_package.fake_module.rst") == self.has_autodoc) if not self.has_autodoc or hasattr(self, "excludes"): assertion = self.assertFalse else: assertion = self.assertTrue assertion(os.path.exists("api/fake_package.fake_private_module.rst"))
def test_different_api_build_dir(self): # Options have to come out of the settings dict as a tuple # showing the source and the value. self.pbr_options['api_doc_dir'] = (None, 'contributor/api') build_doc = packaging.LocalBuildDoc(self.distr) build_doc.run() print('PBR OPTIONS:', self.pbr_options) print('DISTR OPTIONS:', self.distr.command_options) self.assertTrue(os.path.exists("contributor/api/autoindex.rst")) self.assertTrue( os.path.exists("contributor/api/fake_package.fake_module.rst")) self.assertTrue( os.path.exists( "contributor/api/fake_package.fake_private_module.rst"))
def testWarnErrors(self): """Ensure when warnerror is used, we pass warningiserror true""" self.app_init_executed = False def app_init(appSelf, *args, **kwargs): self.assertTrue('warningiserror' in kwargs) self.assertIsInstance(kwargs['warningiserror'], bool) self.assertTrue(kwargs['warningiserror']) appSelf.build = lambda *a, **b: None self.app_init_executed = True self.useFixture(fixtures.MonkeyPatch( "sphinx.application.Sphinx.__init__", app_init)) build_doc = packaging.LocalBuildDoc(self.distr) build_doc.run() self.assertTrue(self.app_init_executed)
def test_cmd_builder_override(self): if self.has_opt: self.distr.command_options["pbr"] = { "autodoc_index_modules": ('setup.cfg', self.autodoc) } self.distr.command_options["build_sphinx"]["builder"] = ( "command line", "non-existing-builder") build_doc = packaging.LocalBuildDoc(self.distr) self.assertNotIn('non-existing-builder', build_doc.builders) self.assertIn('html', build_doc.builders) # process command line options which should override config build_doc.finalize_options() self.assertIn('non-existing-builder', build_doc.builders) self.assertNotIn('html', build_doc.builders)