From 5ae8d7b03cb42c4095fb88a3489e2d862ad40198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xavier=20dupr=C3=A9?= Date: Mon, 14 Mar 2022 22:56:15 +0100 Subject: [PATCH 1/7] Simplifications --- .../sphinxext/sphinximages/sphinxtrib/images.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/pyquickhelper/sphinxext/sphinximages/sphinxtrib/images.py b/src/pyquickhelper/sphinxext/sphinximages/sphinxtrib/images.py index 3280bfb7..857fac07 100644 --- a/src/pyquickhelper/sphinxext/sphinximages/sphinxtrib/images.py +++ b/src/pyquickhelper/sphinxext/sphinximages/sphinxtrib/images.py @@ -323,12 +323,6 @@ def configure_backend(app): # because sphinx try to make a pickle from it. app.sphinxtrib_images_backend = backend - logger = logging.getLogger("image") - logger.info( - 'Initiated images backend: %s:%s', - backend.__class__.__module__, - backend.__class__.__name__) - def backend_methods(node, output_type): "local function" def backend_method(f): From 541ed9d86aca1cf3fbbe05ae421fd94f0577a08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xavier=20dupr=C3=A9?= Date: Mon, 14 Mar 2022 23:52:15 +0100 Subject: [PATCH 2/7] better cleaning of notebooks --- .../having_a_form_in_a_notebook.ipynb | 26 --------------- .../notebooks/td2a_cenonce_session_3A.ipynb | 12 ------- _unittests/ut_helpgen/test_notebooks_bug.py | 32 +------------------ .../ipythonhelper/notebook_helper.py | 14 ++++++-- 4 files changed, 13 insertions(+), 71 deletions(-) diff --git a/_doc/notebooks/having_a_form_in_a_notebook.ipynb b/_doc/notebooks/having_a_form_in_a_notebook.ipynb index 9e7e6158..2eb4c9af 100644 --- a/_doc/notebooks/having_a_form_in_a_notebook.ipynb +++ b/_doc/notebooks/having_a_form_in_a_notebook.ipynb @@ -1116,32 +1116,6 @@ "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" - }, - "widgets": { - "state": { - "6f6cf4a1f7df4a99ba95db615ec86dff": { - "views": [ - { - "cell_index": 20 - } - ] - }, - "c67410ee5aa443b9a6cb53d4f46becec": { - "views": [ - { - "cell_index": 20 - } - ] - }, - "dd3c00717e9d48b99bb5e34462b15fa0": { - "views": [ - { - "cell_index": 20 - } - ] - } - }, - "version": "1.2.0" } }, "nbformat": 4, diff --git a/_unittests/ut_helpgen/notebooks/td2a_cenonce_session_3A.ipynb b/_unittests/ut_helpgen/notebooks/td2a_cenonce_session_3A.ipynb index b24fed5a..95d872cf 100644 --- a/_unittests/ut_helpgen/notebooks/td2a_cenonce_session_3A.ipynb +++ b/_unittests/ut_helpgen/notebooks/td2a_cenonce_session_3A.ipynb @@ -1636,18 +1636,6 @@ "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.5" - }, - "widgets": { - "state": { - "37694361e5da4eb38daa525f8bb2117c": { - "views": [ - { - "cell_index": 9 - } - ] - } - }, - "version": "1.2.0" } }, "nbformat": 4, diff --git a/_unittests/ut_helpgen/test_notebooks_bug.py b/_unittests/ut_helpgen/test_notebooks_bug.py index cdf60c2d..dd4d4629 100644 --- a/_unittests/ut_helpgen/test_notebooks_bug.py +++ b/_unittests/ut_helpgen/test_notebooks_bug.py @@ -5,7 +5,6 @@ import os import unittest import re -from pyquickhelper.loghelper import fLOG from pyquickhelper.helpgen.sphinx_main import process_notebooks from pyquickhelper.pycode import is_travis_or_appveyor, get_temp_folder, ExtTestCase @@ -13,36 +12,24 @@ class TestNoteBooksBug(ExtTestCase): def test_regex(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") exp = re.compile(r"(.{3}[\\]\$)") s = ": [ ['$'," - fLOG(s) r = exp.finditer(s) nb = 0 for _ in r: - fLOG("1", _.groups()) nb += 1 nb1 = nb s = r"\def\PYZdl{\char`\$}" - fLOG(s) r = exp.finditer(s) nb = 0 for _ in r: - fLOG("2", _.groups()) nb += 1 self.assertEqual(nb1, 0) self.assertTrue(nb > 0) def test_notebook(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") path = os.path.abspath(os.path.split(__file__)[0]) fold = os.path.normpath(os.path.join(path, "notebooks")) nbs = [os.path.join(fold, _) @@ -55,7 +42,6 @@ def test_notebook(self): return res = process_notebooks(nbs, temp, temp, formats=formats) - fLOG("*****", len(res)) for _ in res: if not os.path.exists(_[0]): raise Exception(_[0]) @@ -67,10 +53,6 @@ def test_notebook(self): raise Exception(content) def test_notebook_html(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") path = os.path.abspath(os.path.split(__file__)[0]) fold = os.path.normpath(os.path.join(path, "notebooks")) nbs = [os.path.join(fold, _) @@ -83,16 +65,11 @@ def test_notebook_html(self): return res = process_notebooks(nbs, temp, temp, formats=formats) - fLOG("*****", len(res)) for _ in res: if not os.path.exists(_[0]): raise Exception(_[0]) def test_notebook_slides(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") path = os.path.abspath(os.path.split(__file__)[0]) fold = os.path.normpath(os.path.join(path, "notebooks")) nbs = [os.path.join(fold, _) @@ -105,7 +82,6 @@ def test_notebook_slides(self): return res = process_notebooks(nbs, temp, temp, formats=formats) - fLOG("*****", len(res)) for _ in res: if not os.path.exists(_[0]): raise Exception(_[0]) @@ -117,10 +93,6 @@ def test_notebook_slides(self): raise Exception(check) def test_notebook_pdf(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") path = os.path.abspath(os.path.split(__file__)[0]) fold = os.path.normpath(os.path.join(path, "notebooks")) nbs = [os.path.join(fold, _) @@ -137,9 +109,7 @@ def test_notebook_pdf(self): return res = process_notebooks(nbs, temp, temp, formats=formats) - fLOG("*****", len(res)) for _ in res: - fLOG(_) self.assertExists(_[0]) check = os.path.join(temp, "td1a_correction_session4.tex") @@ -150,4 +120,4 @@ def test_notebook_pdf(self): if __name__ == "__main__": - unittest.main() + unittest.main(verbosity=2) diff --git a/src/pyquickhelper/ipythonhelper/notebook_helper.py b/src/pyquickhelper/ipythonhelper/notebook_helper.py index 94ffe69f..cd960822 100644 --- a/src/pyquickhelper/ipythonhelper/notebook_helper.py +++ b/src/pyquickhelper/ipythonhelper/notebook_helper.py @@ -451,7 +451,8 @@ def remove_execution_number(infile, outfile=None, encoding="utf-8", indent=2, ru @param indent indentation @param rule determines the rule which specifies execution numbers, 'None' for None, 'int' for consectuive integers numbers. - @return modified string or None if outfile is not None and the file was not modified + @return modified string or None if outfile is not None + and the file was not modified .. todoext:: :title: remove execution number from notebook facilitate git versionning @@ -465,7 +466,8 @@ def remove_execution_number(infile, outfile=None, encoding="utf-8", indent=2, ru Remove execution number from the notebook to avoid commiting changes only about those numbers - `notebook 5.1.0 `_ + `notebook 5.1.0 + `_ introduced changes which are incompatible with leaving the cell executing number empty. """ @@ -497,9 +499,17 @@ def fixup(adict, k, v, cellno=0, outputs="outputs"): outputs=outputs) return cellno + def widget(adict): + metadata = adict.get('metadata', None) + if metadata is None: + return + if 'widgets' in metadata: + del metadata['widgets'] + content = read_content_ufs(infile) js = json.loads(content) fixup(js, "execution_count", None) + widget(js) st = StringIO() json.dump(js, st, indent=indent, sort_keys=True) res = st.getvalue() From 303d59a5e5c7e3c87d57cdeaecb8e2d19c6c1e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xavier=20dupr=C3=A9?= Date: Sun, 24 Jul 2022 17:01:07 +0200 Subject: [PATCH 3/7] Adds missing variable env for sphinx application --- .../sphinxm_convert_doc_sphinx_helper.py | 145 ++++++------------ 1 file changed, 50 insertions(+), 95 deletions(-) diff --git a/src/pyquickhelper/helpgen/sphinxm_convert_doc_sphinx_helper.py b/src/pyquickhelper/helpgen/sphinxm_convert_doc_sphinx_helper.py index 5a61797d..6f10ec60 100644 --- a/src/pyquickhelper/helpgen/sphinxm_convert_doc_sphinx_helper.py +++ b/src/pyquickhelper/helpgen/sphinxm_convert_doc_sphinx_helper.py @@ -131,12 +131,12 @@ def eval_expr(self, expr): doctree = self.output_format in ('doctree', 'doctree.txt') if not(rst or html or latex or md or doctree): raise ValueError( # pragma: no cover - "Unknown output format '{0}'.".format(self.output_format)) + f"Unknown output format '{self.output_format}'.") try: ev = eval(expr) except Exception: # pragma: no cover raise ValueError( - "Unable to interpret expression '{0}'".format(expr)) + f"Unable to interpret expression '{expr}'") return ev def visit_only(self, node): @@ -258,7 +258,7 @@ def __init__(self, document, builder, *args, **kwds): builder, document = document, builder if not hasattr(builder, "config"): raise TypeError( # pragma: no cover - "Builder has no config: {} - {}".format(type(builder), type(document))) + f"Builder has no config: {type(builder)} - {type(document)}") EnhancedLaTeXTranslator.__init__( self, document, builder, *args, **kwds) _AdditionalVisitDepart.__init__(self, 'md') @@ -433,17 +433,22 @@ def __init__(self, builder=None, app=None): # pylint: disable=W0231 self, EnhancedLaTeXWriter, LatexTranslatorWithCustomDirectives, app) if not hasattr(self.builder, "config"): raise TypeError( # pragma: no cover - "Builder has no config: {}".format(type(self.builder))) + f"Builder has no config: {type(self.builder)}") def translate(self): if not hasattr(self.builder, "config"): raise TypeError( # pragma: no cover - "Builder has no config: {}".format(type(self.builder))) + f"Builder has no config: {type(self.builder)}") # The instruction # visitor = self.builder.create_translator(self.document, self.builder) # automatically adds methods visit_ and depart_ for translator # based on the list of registered extensions. Might be worth using it. - visitor = self.translator_class(self.document, self.builder) + theme = self.builder.themes.get('manual') + if theme is None: + raise RuntimeError( # pragma: no cover + "theme cannot be None.") + visitor = self.translator_class( + self.document, self.builder, theme=theme) self.document.walkabout(visitor) self.output = visitor.body @@ -455,7 +460,7 @@ class _MemoryBuilder: :epkg:`builderapi`. """ - def _init(self, base_class, app): + def _init(self, base_class, app, env=None): """ Constructs the builder. Most of the parameter are static members of the class and cannot @@ -463,6 +468,7 @@ def _init(self, base_class, app): :param base_class: base builder class :param app: :epkg:`Sphinx application` + :param env: Environment """ if "IMPOSSIBLE:TOFIND" in app.srcdir: import sphinx.util.osutil @@ -470,7 +476,7 @@ def _init(self, base_class, app): sphinx.util.osutil.ensuredir = custom_ensuredir sphinx.builders.ensuredir = custom_ensuredir - base_class.__init__(self, app=app) + base_class.__init__(self, app=app, env=env) self.built_pages = {} self.base_class = base_class @@ -558,15 +564,15 @@ def get_target_uri(self, docname, typ=None): return self.config.master_doc + '-#' + docname else: docs = ", ".join( # pragma: no cover - sorted("'{0}'".format(_) for _ in self.env.all_docs)) + sorted(f"'{_}'" for _ in self.env.all_docs)) raise ValueError( # pragma: no cover - "docname='{0}' should be in 'self.env.all_docs' which contains:\n{1}".format(docname, docs)) + f"docname='{docname}' should be in 'self.env.all_docs' which contains:\n{docs}") def get_outfilename(self, pagename): """ Overwrites *get_target_uri* to control file names. """ - return "{0}/{1}.m.html".format(self.outdir, pagename).replace("\\", "/") + return f"{self.outdir}/{pagename}.m.html".replace("\\", "/") def handle_page(self, pagename, addctx, templatename='page.html', outfilename=None, event_arg=None): @@ -606,8 +612,8 @@ def css_tag(css): if value is not None: attrs.append('%s="%s"' % (key, htmlescape( # pylint: disable=W1505 value, True))) # pylint: disable=W1505 - attrs.append('href="%s"' % pathto(css.filename, resource=True)) - return '' % ' '.join(attrs) + attrs.append(f'href="{pathto(css.filename, resource=True)}"') + return f"" ctx['css_tag'] = css_tag def hasdoc(name): @@ -665,7 +671,7 @@ class MemoryHTMLBuilder(_MemoryBuilder, CustomSingleFileHTMLBuilder): supported_data_uri_images = True html_scaled_image_link = True - def __init__(self, app): # pylint: disable=W0231 + def __init__(self, app, env=None): # pylint: disable=W0231 """ Construct the builder. Most of the parameter are static members of the class and cannot @@ -673,7 +679,7 @@ def __init__(self, app): # pylint: disable=W0231 :param app: :epkg:`Sphinx application` """ - _MemoryBuilder._init(self, CustomSingleFileHTMLBuilder, app) + _MemoryBuilder._init(self, CustomSingleFileHTMLBuilder, app, env=env) class MemoryRSTBuilder(_MemoryBuilder, RstBuilder): @@ -697,7 +703,7 @@ class MemoryRSTBuilder(_MemoryBuilder, RstBuilder): supported_data_uri_images = True html_scaled_image_link = True - def __init__(self, app): # pylint: disable=W0231 + def __init__(self, app, env=None): # pylint: disable=W0231 """ Construct the builder. Most of the parameter are static members of the class and cannot @@ -705,7 +711,7 @@ def __init__(self, app): # pylint: disable=W0231 :param app: :epkg:`Sphinx application` """ - _MemoryBuilder._init(self, RstBuilder, app) + _MemoryBuilder._init(self, RstBuilder, app, env=env) def handle_page(self, pagename, addctx, templatename=None, outfilename=None, event_arg=None): @@ -739,7 +745,7 @@ class MemoryMDBuilder(_MemoryBuilder, MdBuilder): supported_data_uri_images = True html_scaled_image_link = True - def __init__(self, app): # pylint: disable=W0231 + def __init__(self, app, env=None): # pylint: disable=W0231 """ Construct the builder. Most of the parameter are static members of the class and cannot @@ -747,7 +753,7 @@ def __init__(self, app): # pylint: disable=W0231 :param app: :epkg:`Sphinx application` """ - _MemoryBuilder._init(self, MdBuilder, app) + _MemoryBuilder._init(self, MdBuilder, app, env=env) def handle_page(self, pagename, addctx, templatename=None, outfilename=None, event_arg=None): @@ -780,7 +786,7 @@ class MemoryDocTreeBuilder(_MemoryBuilder, DocTreeBuilder): supported_data_uri_images = True html_scaled_image_link = True - def __init__(self, app): # pylint: disable=W0231 + def __init__(self, app, env=None): # pylint: disable=W0231 """ Constructs the builder. Most of the parameter are static members of the class and cannot @@ -788,7 +794,7 @@ def __init__(self, app): # pylint: disable=W0231 :param app: :epkg:`Sphinx application` """ - _MemoryBuilder._init(self, DocTreeBuilder, app) + _MemoryBuilder._init(self, DocTreeBuilder, app, env=env) def handle_page(self, pagename, addctx, templatename=None, outfilename=None, event_arg=None): @@ -822,7 +828,7 @@ class MemoryLatexBuilder(_MemoryBuilder, EnhancedLaTeXBuilder): supported_data_uri_images = True html_scaled_image_link = True - def __init__(self, app): # pylint: disable=W0231 + def __init__(self, app, env=None): # pylint: disable=W0231 """ Constructs the builder. Most of the parameter are static members of the class and cannot @@ -830,7 +836,7 @@ def __init__(self, app): # pylint: disable=W0231 :param app: :epkg:`Sphinx application` """ - _MemoryBuilder._init(self, EnhancedLaTeXBuilder, app) + _MemoryBuilder._init(self, EnhancedLaTeXBuilder, app, env=env) def write_stylesheet(self): from sphinx.highlighting import PygmentsBridge @@ -855,7 +861,7 @@ def write(self, content): def _get_filename(self, targetname, encoding='utf-8', overwrite_if_changed=True): if not isinstance(targetname, str): raise TypeError( # pragma: no cover - "targetname must be a string: {0}".format(targetname)) + f"targetname must be a string: {targetname}") destination = MemoryLatexBuilder.EnhancedStringIO() self.built_pages[targetname] = destination return destination @@ -1028,8 +1034,7 @@ def __init__(self, srcdir, confdir, outdir, doctreedir, buildername="memoryhtml" # say hello to the world from sphinx import __display_version__ - self.info('Running Sphinx v%s' % - __display_version__) # pragma: no cover + self.info(f'Running Sphinx v{__display_version__}') # pragma: no cover # notice for parallel build on macOS and py38+ if sys.version_info > (3, 8) and platform.system() == 'Darwin' and parallel > 1: @@ -1043,13 +1048,7 @@ def __init__(self, srcdir, confdir, outdir, doctreedir, buildername="memoryhtml" # delayed import to speed up time from sphinx.application import builtin_extensions - try: - from sphinx.application import CONFIG_FILENAME, Config, Tags - sphinx_version = 2 # pragma: no cover - except ImportError: - # Sphinx 3.0.0 - from sphinx.config import CONFIG_FILENAME, Config, Tags - sphinx_version = 3 + from sphinx.config import CONFIG_FILENAME, Config, Tags # read config self.tags = Tags(tags) @@ -1076,11 +1075,6 @@ def __init__(self, srcdir, confdir, outdir, doctreedir, buildername="memoryhtml" self.sphinx__display_version__ = __display_version__ # create the environment - if sphinx_version == 2: # pragma: no cover - with warnings.catch_warnings(): - warnings.simplefilter( - "ignore", (DeprecationWarning, PendingDeprecationWarning, ImportWarning)) - self.config.check_unicode() self.config.pre_init_values() # set up translation infrastructure @@ -1152,7 +1146,7 @@ def __init__(self, srcdir, confdir, outdir, doctreedir, buildername="memoryhtml" # the config file itself can be an extension if self.config.setup: - prefix = 'while setting up extension %s:' % "conf.py" + prefix = f"while setting up extension {'conf.py'}:" if prefixed_warnings is not None: with prefixed_warnings(prefix): if callable(self.config.setup): @@ -1218,7 +1212,7 @@ def _citems(): if not isinstance(self.env, _CustomBuildEnvironment): raise TypeError( # pragma: no cover - "self.env is not _CustomBuildEnvironment: '{0}' buildername='{1}'".format(type(self.env), buildername)) + f"self.env is not _CustomBuildEnvironment: '{type(self.env)}' buildername='{buildername}'") # addition self._extended_init_() @@ -1247,7 +1241,7 @@ def _init_env(self, freshenv): self.env.setup(self) self.info('done') except Exception as err: - self.info('failed: %s' % err) + self.info('failed: %r', err) self._init_env(freshenv=True) elif self.env is None: # pragma: no cover self.env = _CustomBuildEnvironment(self) @@ -1265,7 +1259,7 @@ def create_builder(self, name): raise ValueError( # pragma: no cover "Builder name cannot be None") - return self.registry.create_builder(self, name) + return self.registry.create_builder(self, name, env=self.env) def _extended_init_(self): """ @@ -1309,7 +1303,7 @@ def finalize(self, doctree, external_docnames=None): if not isinstance(self.env, _CustomBuildEnvironment): raise TypeError( # pragma: no cover - "self.env is not _CustomBuildEnvironment: '{0}'".format(type(self.env))) + f"self.env is not _CustomBuildEnvironment: '{type(self.env)}'") if not isinstance(self.builder.env, _CustomBuildEnvironment): raise TypeError( # pragma: no cover "self.builder.env is not _CustomBuildEnvironment: '{0}'".format( @@ -1356,12 +1350,7 @@ def add_builder(self, builder, override=False): self._added_objects.append(('builder', builder)) if builder.name not in self.registry.builders: self.debug('[_CustomSphinx] adding builder: %r', builder) - try: - # Sphinx >= 1.8 - self.registry.add_builder(builder, override=override) - except TypeError: # pragma: no cover - # Sphinx < 1.8 - self.registry.add_builder(builder) + self.registry.add_builder(builder, override=override) else: self.debug('[_CustomSphinx] already added builder: %r', builder) @@ -1380,11 +1369,11 @@ def setup_extension(self, extname): self.registry.load_extension(self, extname) except Exception as e: # pragma: no cover raise ExtensionError( - "Unable to setup extension '{0}'".format(extname)) from e + f"Unable to setup extension '{extname}'") from e finally: logger.logger = disa - def add_directive(self, name, obj, content=None, arguments=None, # pylint: disable=W0221 + def add_directive(self, name, obj, content=None, arguments=None, # pylint: disable=W0221,W0237 override=True, **options): self._added_objects.append(('directive', name)) if name == 'plot' and obj.__name__ == 'PlotDirective': @@ -1394,64 +1383,36 @@ def add_directive(self, name, obj, content=None, arguments=None, # pylint: disa def run(self): """Run the plot directive.""" logger = getLogger("MockSphinxApp") - logger.info( - '[MockSphinxApp] PlotDirective: {}'.format(self.content)) + logger.info('[MockSphinxApp] PlotDirective: %r', self.content) try: res = old_run(self) - logger.info( - '[MockSphinxApp] PlotDirective ok') + logger.info('[MockSphinxApp] PlotDirective ok') return res except OSError as e: # pragma: no cover logger = getLogger("MockSphinxApp") - logger.info( - '[MockSphinxApp] PlotDirective failed: {}'.format(e)) + logger.info('[MockSphinxApp] PlotDirective failed: %s', e) return [] obj.run = run - try: - # Sphinx >= 1.8 - Sphinx.add_directive(self, name, obj, content=content, # pylint: disable=E1123 - arguments=arguments, - override=override, **options) - except TypeError: - # Sphinx >= 3.0.0 - Sphinx.add_directive(self, name, obj, override=override, **options) - except ExtensionError: # pragma: no cover - # Sphinx < 1.8 - Sphinx.add_directive(self, name, obj, content=content, # pylint: disable=E1123 - arguments=arguments, **options) + Sphinx.add_directive(self, name, obj, override=override, **options) def add_domain(self, domain, override=True): self._added_objects.append(('domain', domain)) - try: - # Sphinx >= 1.8 - Sphinx.add_domain(self, domain, override=override) - except TypeError: # pragma: no cover - # Sphinx < 1.8 - Sphinx.add_domain(self, domain) + Sphinx.add_domain(self, domain, override=override) # For some reason, the directives are missing from the main catalog # in docutils. for k, v in domain.directives.items(): - self.add_directive("{0}:{1}".format(domain.name, k), v) + self.add_directive(f"{domain.name}:{k}", v) if domain.name in ('py', 'std', 'rst'): # We add the directive without the domain name as a prefix. self.add_directive(k, v) for k, v in domain.roles.items(): - self.add_role("{0}:{1}".format(domain.name, k), v) + self.add_role(f"{domain.name}:{k}", v) if domain.name in ('py', 'std', 'rst'): # We add the role without the domain name as a prefix. self.add_role(k, v) - def override_domain(self, domain): - self._added_objects.append(('domain-over', domain)) - try: - Sphinx.override_domain(self, domain) - except AttributeError: # pragma: no cover - # Sphinx==3.0.0 - raise AttributeError( - "override_domain not available in sphinx==3.0.0") - def add_role(self, name, role, override=True): self._added_objects.append(('role', name)) self.debug('[_CustomSphinx] adding role: %r', (name, role)) @@ -1511,17 +1472,11 @@ def add_config_value(self, name, default, rebuild, types_=()): # pylint: disabl self._added_objects.append(('config_value', name)) Sphinx.add_config_value(self, name, default, rebuild, types_) - def add_directive_to_domain(self, domain, name, obj, has_content=None, # pylint: disable=W0221 + def add_directive_to_domain(self, domain, name, obj, has_content=None, # pylint: disable=W0221,W0237 argument_spec=None, override=False, **option_spec): self._added_objects.append(('directive_to_domain', domain, name)) - try: - Sphinx.add_directive_to_domain(self, domain, name, obj, # pylint: disable=E1123 - has_content=has_content, argument_spec=argument_spec, - override=override, **option_spec) - except TypeError: # pragma: no cover - # Sphinx==3.0.0 - Sphinx.add_directive_to_domain(self, domain, name, obj, - override=override, **option_spec) + Sphinx.add_directive_to_domain(self, domain, name, obj, + override=override, **option_spec) def add_role_to_domain(self, domain, name, role, override=False): self._added_objects.append(('roles_to_domain', domain, name)) From cd99acf8697396f212594cf14918c2623594083a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xavier=20dupr=C3=A9?= Date: Sun, 24 Jul 2022 17:41:35 +0200 Subject: [PATCH 4/7] update for latest sphinx --- _unittests/ut_helpgen/test_rst2html.py | 31 ++++--------------- .../ut_sphinxext/test_builders_missing.py | 3 +- .../ut_sphinxext/test_tocdelay_extension.py | 6 +++- .../sphinxm_convert_doc_sphinx_helper.py | 1 + .../sphinxext/sphinx_latex_builder.py | 16 ++++++++-- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/_unittests/ut_helpgen/test_rst2html.py b/_unittests/ut_helpgen/test_rst2html.py index 0ee3b459..18c03968 100644 --- a/_unittests/ut_helpgen/test_rst2html.py +++ b/_unittests/ut_helpgen/test_rst2html.py @@ -2,24 +2,17 @@ @brief test log(time=8s) @author Xavier Dupre """ - -import sys import os import unittest - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder, is_travis_or_appveyor +from pyquickhelper.pycode import ( + get_temp_folder, is_travis_or_appveyor, ignore_warnings) from pyquickhelper.helpgen import rst2html class TestRst2Html(unittest.TestCase): + @ignore_warnings(PendingDeprecationWarning) def test_rst2html_png(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - if is_travis_or_appveyor() in ('travis', 'appveyor'): # It requires latex. return @@ -41,12 +34,8 @@ def test_rst2html_png(self): f.write(text) self.assertTrue(len(text2) > len(text)) + @ignore_warnings(PendingDeprecationWarning) def test_rst2html_svg(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - if is_travis_or_appveyor() in ('travis', 'appveyor'): # It requires latex. return @@ -66,12 +55,8 @@ def test_rst2html_svg(self): f.write(text) self.assertTrue(len(text2) > len(text)) + @ignore_warnings(PendingDeprecationWarning) def test_rst2html_plot_rst(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - temp = get_temp_folder(__file__, "temp_rst2html_plot_rst") rst = os.path.join(os.path.abspath( os.path.dirname(__file__)), "data", "rstplot.rst") @@ -90,12 +75,8 @@ def test_rst2html_plot_rst(self): with open(ji, "w", encoding="utf-8") as f: f.write(text) + @ignore_warnings(PendingDeprecationWarning) def test_rst2html_plot_html(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - temp = get_temp_folder(__file__, "temp_rst2html_plot_html") rst = os.path.join(os.path.abspath( os.path.dirname(__file__)), "data", "rstplot.rst") diff --git a/_unittests/ut_sphinxext/test_builders_missing.py b/_unittests/ut_sphinxext/test_builders_missing.py index 5c742b96..546b1f0e 100644 --- a/_unittests/ut_sphinxext/test_builders_missing.py +++ b/_unittests/ut_sphinxext/test_builders_missing.py @@ -4,7 +4,7 @@ """ import os import unittest -from pyquickhelper.pycode import ExtTestCase +from pyquickhelper.pycode import ExtTestCase, ignore_warnings from pyquickhelper.sphinxext.sphinx_doctree_builder import DocTreeTranslator from pyquickhelper.sphinxext.sphinx_latex_builder import EnhancedLaTeXTranslator from pyquickhelper.sphinxext.sphinx_md_builder import MdTranslator @@ -13,6 +13,7 @@ class TestBuildersMissing(ExtTestCase): + @ignore_warnings(PendingDeprecationWarning) def test_builders_missing(self): from docutils import nodes as skip_ from sphinx.builders.latex.util import ExtBabel diff --git a/_unittests/ut_sphinxext/test_tocdelay_extension.py b/_unittests/ut_sphinxext/test_tocdelay_extension.py index 0f357c1b..39da0bc4 100644 --- a/_unittests/ut_sphinxext/test_tocdelay_extension.py +++ b/_unittests/ut_sphinxext/test_tocdelay_extension.py @@ -9,7 +9,7 @@ import warnings from docutils.parsers.rst import directives from sphinx.errors import ExtensionError -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ignore_warnings from pyquickhelper.helpgen import rst2html, rst2rst_folder from pyquickhelper.sphinxext import TocDelayDirective @@ -19,6 +19,7 @@ class TestTocDelayExtension(unittest.TestCase): def test_post_parse(self): directives.register_directive("tocdelay", TocDelayDirective) + @ignore_warnings(PendingDeprecationWarning) def test_regex(self): s = "2016-06-11 - Make a reference to a blog post <2016/2016-06-11_blogpost_with_label>" reg = TocDelayDirective.regex_title @@ -28,6 +29,7 @@ def test_regex(self): ("2016-06-11 - Make a reference to a blog post", "2016/2016-06-11_blogpost_with_label")) + @ignore_warnings(PendingDeprecationWarning) def test_tocdelay1(self): content = """ .. tocdelay:: @@ -41,6 +43,7 @@ def test_tocdelay1(self): except ValueError as e: self.assertIn("No found document", str(e)) + @ignore_warnings(PendingDeprecationWarning) def test_tocdelay2(self): path = os.path.abspath(os.path.dirname(__file__)) path = os.path.join(path, "data", "blog") @@ -58,6 +61,7 @@ def test_tocdelay2(self): self.assertIn( "event 'doctree-resolved' threw an exception", str(e)) + @ignore_warnings(PendingDeprecationWarning) def test_tocdelay3(self): temp = get_temp_folder(__file__, "temp_tocdelay3") path = os.path.abspath(os.path.dirname(__file__)) diff --git a/src/pyquickhelper/helpgen/sphinxm_convert_doc_sphinx_helper.py b/src/pyquickhelper/helpgen/sphinxm_convert_doc_sphinx_helper.py index 6f10ec60..22f7eef7 100644 --- a/src/pyquickhelper/helpgen/sphinxm_convert_doc_sphinx_helper.py +++ b/src/pyquickhelper/helpgen/sphinxm_convert_doc_sphinx_helper.py @@ -999,6 +999,7 @@ def __init__(self, srcdir, confdir, outdir, doctreedir, buildername="memoryhtml" self.project = None self.registry = SphinxComponentRegistry() self.post_transforms = [] + self.pdb = False if doctreedir is None: doctreedir = "IMPOSSIBLE:TOFIND" diff --git a/src/pyquickhelper/sphinxext/sphinx_latex_builder.py b/src/pyquickhelper/sphinxext/sphinx_latex_builder.py index a5ea88dd..5c9e3ae3 100644 --- a/src/pyquickhelper/sphinxext/sphinx_latex_builder.py +++ b/src/pyquickhelper/sphinxext/sphinx_latex_builder.py @@ -29,17 +29,29 @@ def write(self, data): return res +class DummySphinxTheme: + """ + Dummy theme for sphinx. + """ + + def __init__(self): + self.toplevel_sectioning = "section" + + + class EnhancedLaTeXTranslator(LaTeXTranslator): """ Overwrites `LaTeXTranslator `_ and modifies a few functions. """ - def __init__(self, document, builder): + def __init__(self, document, builder, theme=None): if not hasattr(builder, 'config'): raise TypeError( "Unexpected type for builder {0}".format(type(builder))) - LaTeXTranslator.__init__(self, document, builder) + if theme is None: + theme = DummySphinxTheme() + LaTeXTranslator.__init__(self, document, builder, theme=theme) newlines = builder.config.text_newlines if newlines == 'windows': From e495983468b3c32b2d5936f78c9ede17270fc5ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xavier=20dupr=C3=A9?= Date: Sun, 24 Jul 2022 17:49:39 +0200 Subject: [PATCH 5/7] lint --- src/pyquickhelper/sphinxext/sphinx_latex_builder.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pyquickhelper/sphinxext/sphinx_latex_builder.py b/src/pyquickhelper/sphinxext/sphinx_latex_builder.py index 26bc6513..d0928958 100644 --- a/src/pyquickhelper/sphinxext/sphinx_latex_builder.py +++ b/src/pyquickhelper/sphinxext/sphinx_latex_builder.py @@ -36,7 +36,6 @@ class DummySphinxTheme: def __init__(self): self.toplevel_sectioning = "section" - class EnhancedLaTeXTranslator(LaTeXTranslator): From e929c52032bffd721340c6a84e85cb6b948d5bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xavier=20dupr=C3=A9?= Date: Mon, 25 Jul 2022 10:56:27 +0200 Subject: [PATCH 6/7] remove flog, sys in some unit tests --- _unittests/ut_sphinxext/test_autosignature.py | 6 +- .../ut_sphinxext/test_autosignature_bug.py | 9 +- .../ut_sphinxext/test_bigger_extension.py | 30 ++----- .../ut_sphinxext/test_blocref_extension.py | 47 +++------- .../ut_sphinxext/test_blog_extension.py | 21 +++-- _unittests/ut_sphinxext/test_blog_helper.py | 14 +-- _unittests/ut_sphinxext/test_blog_list.py | 14 +-- .../ut_sphinxext/test_bokeh_extension.py | 14 +-- .../ut_sphinxext/test_cmdref_extension.py | 31 ++++--- .../ut_sphinxext/test_collapse_extension.py | 12 +-- _unittests/ut_sphinxext/test_doc_bug.py | 12 +-- _unittests/ut_sphinxext/test_docassert.py | 34 +------ .../ut_sphinxext/test_doctree_builder.py | 30 +++---- .../test_downloadlink_extension.py | 3 - .../ut_sphinxext/test_epkg_extension.py | 28 ++---- .../ut_sphinxext/test_exref_extension.py | 35 ++------ _unittests/ut_sphinxext/test_ext_helper.py | 2 - .../ut_sphinxext/test_faqref_extension.py | 34 ++----- .../ut_sphinxext/test_gdot_extension.py | 3 - .../ut_sphinxext/test_githublink_extension.py | 49 ++-------- .../ut_sphinxext/test_gitlog_extension.py | 26 +----- .../ut_sphinxext/test_image_extension.py | 21 +---- .../ut_sphinxext/test_import_any_object.py | 8 +- _unittests/ut_sphinxext/test_latex_builder.py | 27 ++---- .../ut_sphinxext/test_mathdef_extension.py | 51 +++-------- _unittests/ut_sphinxext/test_md_builder.py | 44 +++++---- .../ut_sphinxext/test_nbref_extension.py | 32 ++----- .../test_postcontents_extension.py | 23 +---- .../ut_sphinxext/test_quote_extension.py | 31 +++---- .../ut_sphinxext/test_revealsjs_directives.py | 86 +++++++++--------- _unittests/ut_sphinxext/test_rst_builder.py | 31 +++---- .../ut_sphinxext/test_runpython_code_block.py | 3 - .../ut_sphinxext/test_runpython_context.py | 3 - .../ut_sphinxext/test_runpython_extension.py | 89 +++---------------- .../test_runpython_extension_image.py | 18 +--- .../test_runpython_extension_toggle.py | 20 +---- .../test_runpython_store_in_file.py | 3 - .../ut_sphinxext/test_sharenet_extension.py | 19 ++-- .../test_simpleimage_extension.py | 7 +- _unittests/ut_sphinxext/test_style_doc.py | 18 ++-- .../ut_sphinxext/test_template_extension.py | 32 ++----- .../ut_sphinxext/test_thumbnail_extension.py | 21 +---- .../ut_sphinxext/test_tocdelay_extension.py | 6 +- .../ut_sphinxext/test_todoext_extension.py | 37 ++------ .../ut_sphinxext/test_video_extension.py | 49 +--------- .../ut_sphinxext/test_youtube_extension.py | 45 ++-------- .../sphinxm_convert_doc_sphinx_helper.py | 7 +- 47 files changed, 296 insertions(+), 889 deletions(-) diff --git a/_unittests/ut_sphinxext/test_autosignature.py b/_unittests/ut_sphinxext/test_autosignature.py index 212f3ae6..ded7e875 100644 --- a/_unittests/ut_sphinxext/test_autosignature.py +++ b/_unittests/ut_sphinxext/test_autosignature.py @@ -9,8 +9,10 @@ import numpy from pyquickhelper.loghelper import sys_path_append from pyquickhelper.pycode import ExtTestCase -from pyquickhelper.sphinxext.import_object_helper import import_object, import_any_object, import_path -from pyquickhelper.sphinxext.sphinx_autosignature import enumerate_extract_signature, enumerate_cleaned_signature +from pyquickhelper.sphinxext.import_object_helper import ( + import_object, import_any_object, import_path) +from pyquickhelper.sphinxext.sphinx_autosignature import ( + enumerate_extract_signature, enumerate_cleaned_signature) from pyquickhelper.helpgen import rst2html diff --git a/_unittests/ut_sphinxext/test_autosignature_bug.py b/_unittests/ut_sphinxext/test_autosignature_bug.py index 1a6fa04f..cc4d3967 100644 --- a/_unittests/ut_sphinxext/test_autosignature_bug.py +++ b/_unittests/ut_sphinxext/test_autosignature_bug.py @@ -2,17 +2,16 @@ @brief test log(time=8s) @author Xavier Dupre """ - -import sys import os import unittest import pandas import numpy - from pyquickhelper.loghelper import sys_path_append from pyquickhelper.pycode import ExtTestCase -from pyquickhelper.sphinxext.import_object_helper import import_object, import_any_object, import_path -from pyquickhelper.sphinxext.sphinx_autosignature import enumerate_extract_signature, enumerate_cleaned_signature +from pyquickhelper.sphinxext.import_object_helper import ( + import_object, import_any_object, import_path) +from pyquickhelper.sphinxext.sphinx_autosignature import ( + enumerate_extract_signature, enumerate_cleaned_signature) from pyquickhelper.helpgen import rst2html diff --git a/_unittests/ut_sphinxext/test_bigger_extension.py b/_unittests/ut_sphinxext/test_bigger_extension.py index 0fc1d7d7..7874be7f 100644 --- a/_unittests/ut_sphinxext/test_bigger_extension.py +++ b/_unittests/ut_sphinxext/test_bigger_extension.py @@ -2,14 +2,10 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ignore_warnings from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import bigger_role from docutils.parsers.rst.roles import register_canonical_role @@ -17,20 +13,12 @@ class TestBiggerExtension(unittest.TestCase): + @ignore_warnings(PendingDeprecationWarning) def test_post_parse_sn(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - register_canonical_role("bigger", bigger_role) + @ignore_warnings(PendingDeprecationWarning) def test_bigger(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -45,8 +33,7 @@ def test_bigger(self): this code shoud appear """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="html", keep_warnings=True, @@ -80,12 +67,8 @@ def test_bigger(self): with open(os.path.join(temp, "out_bigger.html"), "w", encoding="utf8") as f: f.write(html) + @ignore_warnings(PendingDeprecationWarning) def test_bigger_inline(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -94,8 +77,7 @@ def test_bigger_inline(self): abeforea :bigger:`facebook` aaftera """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="html", keep_warnings=True, diff --git a/_unittests/ut_sphinxext/test_blocref_extension.py b/_unittests/ut_sphinxext/test_blocref_extension.py index e80257c5..c9984c3b 100644 --- a/_unittests/ut_sphinxext/test_blocref_extension.py +++ b/_unittests/ut_sphinxext/test_blocref_extension.py @@ -2,14 +2,11 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest from docutils.parsers.rst import directives - from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ignore_warnings from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import BlocRef, BlocRefList from pyquickhelper.sphinxext.sphinx_blocref_extension import blocref_node, visit_blocref_node, depart_blocref_node @@ -17,21 +14,13 @@ class TestBlocRefExtension(unittest.TestCase): + @ignore_warnings(PendingDeprecationWarning) def test_post_parse_blocref(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("blocref", BlocRef) directives.register_directive("blocreflist", BlocRefList) + @ignore_warnings(PendingDeprecationWarning) def test_blocref_rst(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -49,8 +38,7 @@ def test_blocref_rst(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("blocref", BlocRef, blocref_node, visit_blocref_node, depart_blocref_node)] @@ -77,12 +65,8 @@ def test_blocref_rst(self): if "= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("blocref", BlocRef, blocref_node, visit_blocref_node, depart_blocref_node)] @@ -128,12 +111,8 @@ def test_blocref_html(self): if "= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("blocref", BlocRef, blocref_node, visit_blocref_node, depart_blocref_node)] @@ -177,12 +155,8 @@ def test_blocref2(self): if t1 not in html: raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_blocreflist(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -207,8 +181,7 @@ def test_blocreflist(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("blocref", BlocRef, blocref_node, visit_blocref_node, depart_blocref_node)] diff --git a/_unittests/ut_sphinxext/test_blog_extension.py b/_unittests/ut_sphinxext/test_blog_extension.py index 307414c1..a1835937 100644 --- a/_unittests/ut_sphinxext/test_blog_extension.py +++ b/_unittests/ut_sphinxext/test_blog_extension.py @@ -2,25 +2,25 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest from docutils.parsers.rst import directives - -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ignore_warnings from pyquickhelper.helpgen import rst2html -from pyquickhelper.sphinxext.sphinx_blog_extension import BlogPostDirective, BlogPostDirectiveAgg -from pyquickhelper.sphinxext.sphinx_blog_extension import blogpost_node, visit_blogpost_node, depart_blogpost_node -from pyquickhelper.sphinxext.sphinx_blog_extension import blogpostagg_node, visit_blogpostagg_node, depart_blogpostagg_node +from pyquickhelper.sphinxext.sphinx_blog_extension import ( + BlogPostDirective, BlogPostDirectiveAgg, + blogpost_node, visit_blogpost_node, depart_blogpost_node, + blogpostagg_node, visit_blogpostagg_node, depart_blogpostagg_node) class TestBlogExtension(unittest.TestCase): + @ignore_warnings(PendingDeprecationWarning) def test_post_parse_blog(self): directives.register_directive("blogpost", BlogPostDirective) directives.register_directive("blogpostagg", BlogPostDirectiveAgg) + @ignore_warnings(PendingDeprecationWarning) def test_blogpost(self): from docutils import nodes as skip_ @@ -42,8 +42,7 @@ def test_blogpost(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("blogpost", BlogPostDirective, blogpost_node, visit_blogpost_node, depart_blogpost_node)] @@ -71,6 +70,7 @@ def test_blogpost(self): self.assertIn('================', text) self.assertIn('after', text) + @ignore_warnings(PendingDeprecationWarning) def test_blogpost_agg(self): from docutils import nodes as skip_ @@ -93,8 +93,7 @@ def test_blogpost_agg(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("blogpostagg", BlogPostDirectiveAgg, blogpostagg_node, visit_blogpostagg_node, depart_blogpostagg_node)] diff --git a/_unittests/ut_sphinxext/test_blog_helper.py b/_unittests/ut_sphinxext/test_blog_helper.py index 34cf6098..79b6adb3 100644 --- a/_unittests/ut_sphinxext/test_blog_helper.py +++ b/_unittests/ut_sphinxext/test_blog_helper.py @@ -2,15 +2,12 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings from docutils.parsers.rst import directives - from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ignore_warnings from pyquickhelper.sphinxext import BlogPost, BlogPostList, BlogPostDirective from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import RunPythonDirective @@ -18,6 +15,7 @@ class TestBlogHelper(unittest.TestCase): + @ignore_warnings(PendingDeprecationWarning) def test_post_parse(self): directives.register_directive("blogpost", BlogPostDirective) @@ -33,6 +31,7 @@ def test_post_parse(self): self.assertEqual( p.Tag, "post-2015-04-04-anexampleofablogpostincludedinthedocumentation") + @ignore_warnings(PendingDeprecationWarning) def test_post_list(self): # the test will fail if you add a file in data/blog others # with rst files which is not a blog post @@ -60,6 +59,7 @@ def test_post_list(self): content = f.read() self.assertIn('...', content) + @ignore_warnings(PendingDeprecationWarning) def test_directive_with_rst2html(self): path = os.path.abspath(os.path.split(__file__)[0]) file = os.path.join(path, "data", "2015-04-04_first_blogpost.rst") @@ -77,6 +77,7 @@ def test_directive_with_rst2html(self): p2 = html.find(t2) fLOG("--------------ERRORS\n", html[p1:p2], "------------") + @ignore_warnings(PendingDeprecationWarning) def test_docutils(self): # from https://gist.github.com/mastbaum/2655700 import docutils.core @@ -129,6 +130,7 @@ def depart_foo(self, node): if "" not in html: raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_newdirective_with_rst2html(self): """ this test also test the extension runpython @@ -155,8 +157,7 @@ def depart_rp_node(self, node): print(u"this code shoud appear" + u"___") """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node, visit_rp_node, depart_rp_node)] @@ -179,6 +180,7 @@ def depart_rp_node(self, node): f.write(html) raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_newdirective_with_rst2html_bug(self): from docutils import nodes diff --git a/_unittests/ut_sphinxext/test_blog_list.py b/_unittests/ut_sphinxext/test_blog_list.py index bdcdff07..17d0c183 100644 --- a/_unittests/ut_sphinxext/test_blog_list.py +++ b/_unittests/ut_sphinxext/test_blog_list.py @@ -2,24 +2,18 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest from docutils.parsers.rst import directives - -from pyquickhelper.loghelper.flog import fLOG +from pyquickhelper.loghelper import fLOG +from pyquickhelper.pycode import ExtTestCase, ignore_warnings from pyquickhelper.sphinxext import BlogPostList, BlogPostDirective -class TestBlogList(unittest.TestCase): +class TestBlogList(ExtTestCase): + @ignore_warnings(PendingDeprecationWarning) def test_blog_list(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("blogpost", BlogPostDirective) path = os.path.abspath(os.path.split(__file__)[0]) diff --git a/_unittests/ut_sphinxext/test_bokeh_extension.py b/_unittests/ut_sphinxext/test_bokeh_extension.py index 71531c23..1acc361d 100644 --- a/_unittests/ut_sphinxext/test_bokeh_extension.py +++ b/_unittests/ut_sphinxext/test_bokeh_extension.py @@ -2,24 +2,17 @@ @brief test log(time=4s) @author Xavier Dupre """ -import sys import os import unittest import warnings - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ignore_warnings from pyquickhelper.helpgen import rst2html class TestBokehExtension(unittest.TestCase): + @ignore_warnings(PendingDeprecationWarning) def test_bokeh(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ from pyquickhelper.sphinxext.bokeh.bokeh_plot import BokehPlotDirective self.assertTrue(BokehPlotDirective is not None) @@ -47,8 +40,7 @@ def test_bokeh(self): show(p) """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="html", keep_warnings=True, diff --git a/_unittests/ut_sphinxext/test_cmdref_extension.py b/_unittests/ut_sphinxext/test_cmdref_extension.py index 2bc715bb..85f151c0 100644 --- a/_unittests/ut_sphinxext/test_cmdref_extension.py +++ b/_unittests/ut_sphinxext/test_cmdref_extension.py @@ -7,18 +7,23 @@ import unittest from docutils.parsers.rst import directives import pyquickhelper -from pyquickhelper.pycode import get_temp_folder, ExtTestCase, is_travis_or_appveyor, skipif_azure_macosx +from pyquickhelper.pycode import ( + get_temp_folder, ExtTestCase, is_travis_or_appveyor, + skipif_azure_macosx) from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import CmdRef, CmdRefList -from pyquickhelper.sphinxext.sphinx_cmdref_extension import cmdref_node, visit_cmdref_node, depart_cmdref_node +from pyquickhelper.sphinxext.sphinx_cmdref_extension import ( + cmdref_node, visit_cmdref_node, depart_cmdref_node) class TestCmdRefExtension(ExtTestCase): + @ignore_warnings(PendingDeprecationWarning) def test_post_parse_cmdref(self): directives.register_directive("cmdref", CmdRef) directives.register_directive("cmdreflist", CmdRefList) + @ignore_warnings(PendingDeprecationWarning) def test_cmdref(self): from docutils import nodes as skip_ @@ -38,8 +43,7 @@ def test_cmdref(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -75,6 +79,7 @@ def test_cmdref(self): if t1 not in html: raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_cmdreflist(self): from docutils import nodes as skip_ @@ -100,8 +105,7 @@ def test_cmdreflist(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -131,6 +135,7 @@ def test_cmdreflist(self): if 'freg0">' in html: raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_cmdref_rename(self): from docutils import nodes as skip_ @@ -150,8 +155,7 @@ def test_cmdref_rename(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -171,6 +175,7 @@ def test_cmdref_rename(self): if t1 not in html: raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_cmdref_quote(self): from docutils import nodes as skip_ @@ -190,8 +195,7 @@ def test_cmdref_quote(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -211,7 +215,9 @@ def test_cmdref_quote(self): if t1 in html: raise Exception(html) - @skipif_azure_macosx("The Mac OS X backend will not be able to function correctly if Python is not installed as a framework.") + @skipif_azure_macosx("The Mac OS X backend will not be able to " + "function correctly if Python is not installed as a framework.") + @ignore_warnings(PendingDeprecationWarning) def test_cmdref_module(self): """ The test fails on MACOSX if it runs from a virtual envrionment. @@ -245,8 +251,7 @@ def test_cmdref_module(self): after """.replace(" ", "").format(path) - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] diff --git a/_unittests/ut_sphinxext/test_collapse_extension.py b/_unittests/ut_sphinxext/test_collapse_extension.py index 8b554396..9927cdc8 100644 --- a/_unittests/ut_sphinxext/test_collapse_extension.py +++ b/_unittests/ut_sphinxext/test_collapse_extension.py @@ -2,12 +2,9 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest from docutils.parsers.rst import directives - from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html @@ -26,8 +23,7 @@ def test_collapse(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') temp = get_temp_folder(__file__, "temp_collapse") @@ -92,8 +88,7 @@ def test_collapse_legend(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') # RST html = rst2html(content, writer="rst", keep_warnings=True) @@ -127,8 +122,7 @@ def test_collapse_show(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') # RST html = rst2html(content, writer="rst", keep_warnings=True) diff --git a/_unittests/ut_sphinxext/test_doc_bug.py b/_unittests/ut_sphinxext/test_doc_bug.py index 49e66934..d635638c 100644 --- a/_unittests/ut_sphinxext/test_doc_bug.py +++ b/_unittests/ut_sphinxext/test_doc_bug.py @@ -2,25 +2,19 @@ @brief test log(time=8s) @author Xavier Dupre """ - -import sys import os import unittest import warnings - from pyquickhelper.loghelper.flog import fLOG +from pyquickhelper.pycode import ExtTestCase, ignore_warnings from pyquickhelper.helpgen import rst2html from pyquickhelper.pycode import get_temp_folder -class TestDocBug(unittest.TestCase): +class TestDocBug(ExtTestCase): + @ignore_warnings(PendingDeprecationWarning) def test_param_sphinx(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ diff --git a/_unittests/ut_sphinxext/test_docassert.py b/_unittests/ut_sphinxext/test_docassert.py index 05ee4a54..b680dfdb 100644 --- a/_unittests/ut_sphinxext/test_docassert.py +++ b/_unittests/ut_sphinxext/test_docassert.py @@ -2,27 +2,22 @@ @brief test log(time=8s) @author Xavier Dupre """ -import sys import os from io import StringIO import unittest import warnings import logging from sphinx.util.logging import getLogger +from pyquickhelper.pycode import ExtTestCase from pyquickhelper.loghelper.flog import fLOG from pyquickhelper.sphinxext.import_object_helper import import_object from pyquickhelper.helpgen import rst2html from pyquickhelper.loghelper import sys_path_append -class TestDocAssert(unittest.TestCase): +class TestDocAssert(ExtTestCase): def test_import_object(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - this = os.path.abspath(os.path.dirname(__file__)) data = os.path.join(this, "datadoc") with sys_path_append(data): @@ -31,11 +26,6 @@ def test_import_object(self): self.assertTrue(obj(4, 5), 9) def test_docassert_html(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - logger1 = getLogger("MockSphinxApp") logger2 = getLogger("docassert") @@ -79,10 +69,6 @@ def test_docassert_html(self): self.assertTrue("a" in html) def test_docassert_html_bug(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") class MyStream: def __init__(self): @@ -128,10 +114,6 @@ def __len__(self): raise Exception("not the right warning") def test_docassert_html_method(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") class MyStream: def __init__(self): @@ -180,10 +162,6 @@ def __len__(self): raise Exception(line) def test_docassert_html_init(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") class MyStream: def __init__(self): @@ -231,10 +209,6 @@ def __len__(self): raise Exception("not the right warning") def test_docassert_html_init2(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") class MyStream: def __init__(self): @@ -282,10 +256,6 @@ def __len__(self): raise Exception("not the right warning") def test_docassert_html_style(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") class MyStream: def __init__(self): diff --git a/_unittests/ut_sphinxext/test_doctree_builder.py b/_unittests/ut_sphinxext/test_doctree_builder.py index f85026aa..bc35edad 100644 --- a/_unittests/ut_sphinxext/test_doctree_builder.py +++ b/_unittests/ut_sphinxext/test_doctree_builder.py @@ -2,15 +2,13 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest - from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import CmdRef -from pyquickhelper.sphinxext.sphinx_cmdref_extension import cmdref_node, visit_cmdref_node, depart_cmdref_node +from pyquickhelper.sphinxext.sphinx_cmdref_extension import ( + cmdref_node, visit_cmdref_node, depart_cmdref_node) class TestDocTreeBuilder(ExtTestCase): @@ -34,8 +32,7 @@ def test_doctree_builder(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -106,8 +103,7 @@ def test_doctree_builder_sphinx(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -168,8 +164,7 @@ def test_doctree_builder_sphinx_table(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -210,8 +205,7 @@ def test_doctree_only(self): not only for doctree """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -242,8 +236,7 @@ def test_doctree_reference(self): :py:class:`Renamed ` """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -301,8 +294,7 @@ def test_doctree_reference2(self): jjjj """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="doctree", keep_warnings=False, layout='sphinx', @@ -334,8 +326,7 @@ def test_doctree_image(self): :width: 200 :alt: alternative2 """.replace(" ", "").format(img1, img2).replace("\\", "/") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') try: text = rst2html(content, # fLOG=fLOG, @@ -365,8 +356,7 @@ def test_doctree_image_target(self): :width: 200 :alt: alternative1 """.replace(" ", "").format(img1).replace("\\", "/") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="doctree", keep_warnings=False, layout='sphinx', diff --git a/_unittests/ut_sphinxext/test_downloadlink_extension.py b/_unittests/ut_sphinxext/test_downloadlink_extension.py index 3c3d677f..9826f364 100644 --- a/_unittests/ut_sphinxext/test_downloadlink_extension.py +++ b/_unittests/ut_sphinxext/test_downloadlink_extension.py @@ -2,13 +2,10 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings import sphinx - from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import process_downloadlink_role diff --git a/_unittests/ut_sphinxext/test_epkg_extension.py b/_unittests/ut_sphinxext/test_epkg_extension.py index 20a18b37..74a00e09 100644 --- a/_unittests/ut_sphinxext/test_epkg_extension.py +++ b/_unittests/ut_sphinxext/test_epkg_extension.py @@ -2,18 +2,15 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings - -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.cli.cli_helper import clean_documentation_for_cli -class TestEpkgExtension(unittest.TestCase): +class TestEpkgExtension(ExtTestCase): def test_epkg_module(self): from docutils import nodes as skip_ @@ -24,8 +21,7 @@ def test_epkg_module(self): abeforea :epkg:`pandas` aaftera """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, writer="custom", keep_warnings=True, directives=None, layout="sphinx", @@ -56,8 +52,7 @@ def test_epkg_module_twice(self): abeforea :epkg:`pandas` aaftera """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, writer="custom", keep_warnings=True, directives=None, layout="sphinx", @@ -76,8 +71,7 @@ def test_epkg_sub(self): 7za :epkg:`7z` 7zb """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, writer="custom", keep_warnings=True, directives=None, layout="sphinx", @@ -122,8 +116,7 @@ def test_epkg_function(self): 7za :epkg:`7z` 7zb """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') def pandas_link(input): return "MYA", "|".join(input.split(":")) @@ -172,8 +165,7 @@ def test_epkg_class(self): 7za :epkg:`7z` 7zb """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') class pandas_link: def __call__(self, input): @@ -223,8 +215,7 @@ def test_epkg_function_string(self): 7za :epkg:`7z` 7zb """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, writer="custom", keep_warnings=True, directives=None, layout="sphinx", @@ -269,8 +260,7 @@ def test_epkg_function_long_link(self): `one link on two lines `_. """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, writer="custom", keep_warnings=True, diff --git a/_unittests/ut_sphinxext/test_exref_extension.py b/_unittests/ut_sphinxext/test_exref_extension.py index 5857a2e2..146dad31 100644 --- a/_unittests/ut_sphinxext/test_exref_extension.py +++ b/_unittests/ut_sphinxext/test_exref_extension.py @@ -2,35 +2,23 @@ @brief test log(time=4s) @author Xavier Dupre """ -import sys import os import unittest from docutils.parsers.rst import directives - -from pyquickhelper.loghelper.flog import fLOG from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import ExRef, ExRefList -from pyquickhelper.sphinxext.sphinx_exref_extension import exref_node, visit_exref_node, depart_exref_node +from pyquickhelper.sphinxext.sphinx_exref_extension import ( + exref_node, visit_exref_node, depart_exref_node) class TestExRefExtension(ExtTestCase): def test_post_parse_exref(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("exref", ExRef) directives.register_directive("exreflist", ExRefList) def test_exref(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -48,8 +36,7 @@ def test_exref(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("exref", ExRef, exref_node, visit_exref_node, depart_exref_node)] @@ -75,11 +62,6 @@ def test_exref(self): raise Exception(html) def test_exreflist(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -103,8 +85,7 @@ def test_exreflist(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("exref", ExRef, exref_node, visit_exref_node, depart_exref_node)] @@ -132,11 +113,6 @@ def test_exreflist(self): raise Exception(html) def test_exreflist_rst(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -160,8 +136,7 @@ def test_exreflist_rst(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("exref", ExRef, exref_node, visit_exref_node, depart_exref_node)] diff --git a/_unittests/ut_sphinxext/test_ext_helper.py b/_unittests/ut_sphinxext/test_ext_helper.py index 42b6b81f..16e47b0d 100644 --- a/_unittests/ut_sphinxext/test_ext_helper.py +++ b/_unittests/ut_sphinxext/test_ext_helper.py @@ -1,11 +1,9 @@ """ @brief test log(time=3s) """ -import sys import os import unittest from docutils.parsers.rst import directives - from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext.sphinx_ext_helper import get_index diff --git a/_unittests/ut_sphinxext/test_faqref_extension.py b/_unittests/ut_sphinxext/test_faqref_extension.py index a7d23dfe..850e2213 100644 --- a/_unittests/ut_sphinxext/test_faqref_extension.py +++ b/_unittests/ut_sphinxext/test_faqref_extension.py @@ -2,36 +2,26 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest from docutils.parsers.rst import directives - from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase, ignore_warnings from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import FaqRef, FaqRefList -from pyquickhelper.sphinxext.sphinx_faqref_extension import faqref_node, visit_faqref_node, depart_faqref_node +from pyquickhelper.sphinxext.sphinx_faqref_extension import ( + faqref_node, visit_faqref_node, depart_faqref_node) -class TestFaqRefExtension(unittest.TestCase): +class TestFaqRefExtension(ExtTestCase): + @ignore_warnings(PendingDeprecationWarning) def test_post_parse_faqref(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("faqref", FaqRef) directives.register_directive("faqreflist", FaqRefList) + @ignore_warnings(PendingDeprecationWarning) def test_faqref(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -49,8 +39,7 @@ def test_faqref(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("faqref", FaqRef, faqref_node, visit_faqref_node, depart_faqref_node)] @@ -75,12 +64,8 @@ def test_faqref(self): if t1 not in html: raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_faqreflist(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -104,8 +89,7 @@ def test_faqreflist(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("faqref", FaqRef, faqref_node, visit_faqref_node, depart_faqref_node)] diff --git a/_unittests/ut_sphinxext/test_gdot_extension.py b/_unittests/ut_sphinxext/test_gdot_extension.py index c2d1cd53..6ca9f48a 100644 --- a/_unittests/ut_sphinxext/test_gdot_extension.py +++ b/_unittests/ut_sphinxext/test_gdot_extension.py @@ -2,13 +2,10 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import logging from docutils.parsers.rst import directives - from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html diff --git a/_unittests/ut_sphinxext/test_githublink_extension.py b/_unittests/ut_sphinxext/test_githublink_extension.py index c679eae4..095560b0 100644 --- a/_unittests/ut_sphinxext/test_githublink_extension.py +++ b/_unittests/ut_sphinxext/test_githublink_extension.py @@ -2,36 +2,21 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import githublink_role from docutils.parsers.rst.roles import register_canonical_role -class TestGitHubLinkExtension(unittest.TestCase): +class TestGitHubLinkExtension(ExtTestCase): def test_post_parse_sn(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - register_canonical_role("githublink", githublink_role) - @unittest.skipIf(sys.version_info[0] < 3, "does not work on Python 2") def test_githublink(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -64,8 +49,7 @@ def test_githublink(self): this code shoud appear """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="custom", keep_warnings=True, @@ -108,13 +92,7 @@ def test_githublink(self): with open(os.path.join(temp, "out_githublink.html"), "w", encoding="utf8") as f: f.write(html) - @unittest.skipIf(sys.version_info[0] < 3, "does not work on Python 2") def test_githublink_function(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -143,8 +121,7 @@ def test_githublink_function(self): this code shoud appear """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') def processor(path, lineno): return f"[{path}:{lineno}]", "my_sources" @@ -187,13 +164,7 @@ def processor(path, lineno): with open(os.path.join(temp, "out_githublink.html"), "w", encoding="utf8") as f: f.write(html) - @unittest.skipIf(sys.version_info[0] < 3, "does not work on Python 2") def test_githublink_doc(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -206,8 +177,7 @@ def test_githublink_doc(self): this code shoud appear """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="custom", keep_warnings=True, @@ -230,13 +200,7 @@ def test_githublink_doc(self): with open(os.path.join(temp, "out_githublink.html"), "w", encoding="utf8") as f: f.write(html) - @unittest.skipIf(sys.version_info[0] < 3, "does not work on Python 2") def test_githublink_binaries(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -255,8 +219,7 @@ def test_githublink_binaries(self): this code shoud appear """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="custom", keep_warnings=True, diff --git a/_unittests/ut_sphinxext/test_gitlog_extension.py b/_unittests/ut_sphinxext/test_gitlog_extension.py index 830d76a5..eb91c79d 100644 --- a/_unittests/ut_sphinxext/test_gitlog_extension.py +++ b/_unittests/ut_sphinxext/test_gitlog_extension.py @@ -2,36 +2,22 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings from datetime import datetime - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import gitlog_role from docutils.parsers.rst.roles import register_canonical_role -class TestGitlogExtension(unittest.TestCase): +class TestGitlogExtension(ExtTestCase): def test_post_parse_sn(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - register_canonical_role("gitlog", gitlog_role) def test_gitlog(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -46,8 +32,7 @@ def test_gitlog(self): this code shoud appear """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="html", keep_warnings=True, @@ -70,11 +55,6 @@ def test_gitlog(self): f.write(html) def test_gitlog_inline(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ diff --git a/_unittests/ut_sphinxext/test_image_extension.py b/_unittests/ut_sphinxext/test_image_extension.py index 2607c902..a9bbb042 100644 --- a/_unittests/ut_sphinxext/test_image_extension.py +++ b/_unittests/ut_sphinxext/test_image_extension.py @@ -2,15 +2,12 @@ @brief test log(time=4s) @author Xavier Dupre """ -import sys import os import logging import unittest import warnings from io import StringIO from docutils.parsers.rst import directives - -from pyquickhelper.loghelper.flog import fLOG from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.helpgen.sphinxm_custom_app import CustomSphinxApp @@ -24,19 +21,9 @@ def setUp(self): logger.disabled = True def test_post_parse_sn(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("image", ImageDirective) def test_image(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -54,8 +41,7 @@ def test_image(self): this code shoud appear """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') logger2 = logging.getLogger("video") @@ -93,11 +79,6 @@ def test_image(self): f.write(html) def test_sphinx_ext_image_html(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - temp = get_temp_folder(__file__, "temp_sphinx_ext_image_html") src_ = os.path.join(temp, "..", "data", "image") diff --git a/_unittests/ut_sphinxext/test_import_any_object.py b/_unittests/ut_sphinxext/test_import_any_object.py index 6cdb2c2e..d3870f6b 100644 --- a/_unittests/ut_sphinxext/test_import_any_object.py +++ b/_unittests/ut_sphinxext/test_import_any_object.py @@ -2,16 +2,16 @@ @brief test log(time=8s) @author Xavier Dupre """ - import sys import os import unittest - -from pyquickhelper.sphinxext.import_object_helper import import_any_object, import_object +from pyquickhelper.sphinxext.import_object_helper import ( + import_any_object, import_object) +from pyquickhelper.pycode import ExtTestCase from pyquickhelper.loghelper import sys_path_append -class TestImportAnyObject(unittest.TestCase): +class TestImportAnyObject(ExtTestCase): def test_import_any_object(self): this = os.path.abspath(os.path.dirname(__file__)) diff --git a/_unittests/ut_sphinxext/test_latex_builder.py b/_unittests/ut_sphinxext/test_latex_builder.py index 4150c049..fa77285a 100644 --- a/_unittests/ut_sphinxext/test_latex_builder.py +++ b/_unittests/ut_sphinxext/test_latex_builder.py @@ -2,11 +2,8 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest - from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import CmdRef @@ -94,8 +91,7 @@ def test_latex_builder_sphinx(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -152,8 +148,7 @@ def test_latex_builder_sphinx_table(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -195,8 +190,7 @@ def test_latex_only(self): only for md """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -242,8 +236,7 @@ def test_latex_reference(self): :py:class:`Renamed ` """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -308,8 +301,7 @@ def test_latex_reference2(self): jjjj """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="elatex", keep_warnings=False, layout='sphinx', @@ -344,8 +336,7 @@ def test_latex_title(self): ****** """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="elatex", keep_warnings=False, layout='sphinx', @@ -374,8 +365,7 @@ def test_latex_image(self): :width: 59 :alt: alternative2 """.replace(" ", "").format(img1, img2).replace("\\", "/") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="elatex", keep_warnings=False, layout='sphinx', @@ -406,8 +396,7 @@ def test_latex_image_overwrite(self): :width: 59 :alt: alternative2 """.replace(" ", "").format(img1, img2).replace("\\", "/") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="elatex", keep_warnings=False, layout='sphinx', diff --git a/_unittests/ut_sphinxext/test_mathdef_extension.py b/_unittests/ut_sphinxext/test_mathdef_extension.py index d97b3baf..1fe6af3a 100644 --- a/_unittests/ut_sphinxext/test_mathdef_extension.py +++ b/_unittests/ut_sphinxext/test_mathdef_extension.py @@ -2,36 +2,25 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest from docutils.parsers.rst import directives - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ignore_warnings from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import MathDef, MathDefList -from pyquickhelper.sphinxext.sphinx_mathdef_extension import mathdef_node, visit_mathdef_node, depart_mathdef_node +from pyquickhelper.sphinxext.sphinx_mathdef_extension import ( + mathdef_node, visit_mathdef_node, depart_mathdef_node) class TestMathDefExtension(unittest.TestCase): + @ignore_warnings(PendingDeprecationWarning) def test_post_parse_sn_todoext(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("mathdef", MathDef) directives.register_directive("mathdeflist", MathDefList) + @ignore_warnings(PendingDeprecationWarning) def test_mathdef(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -49,8 +38,7 @@ def test_mathdef(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("mathdef", MathDef, mathdef_node, visit_mathdef_node, depart_mathdef_node)] @@ -75,12 +63,8 @@ def test_mathdef(self): if t1 not in html: raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_mathdeflist(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -102,8 +86,7 @@ def test_mathdeflist(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("mathdef", MathDef, mathdef_node, visit_mathdef_node, depart_mathdef_node)] @@ -128,12 +111,8 @@ def test_mathdeflist(self): if t1 not in html: raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_mathdeflist_contents(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -156,8 +135,7 @@ def test_mathdeflist_contents(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("mathdef", MathDef, mathdef_node, visit_mathdef_node, depart_mathdef_node)] @@ -182,12 +160,8 @@ def test_mathdeflist_contents(self): if t1 not in html: raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_mathdeflist_contents_body_sphinx(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -216,8 +190,7 @@ def test_mathdeflist_contents_body_sphinx(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("mathdef", MathDef, mathdef_node, visit_mathdef_node, depart_mathdef_node)] diff --git a/_unittests/ut_sphinxext/test_md_builder.py b/_unittests/ut_sphinxext/test_md_builder.py index d912bf06..64d81d37 100644 --- a/_unittests/ut_sphinxext/test_md_builder.py +++ b/_unittests/ut_sphinxext/test_md_builder.py @@ -2,19 +2,18 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest - -from pyquickhelper.pycode import get_temp_folder, ExtTestCase +from pyquickhelper.pycode import get_temp_folder, ExtTestCase, ignore_warnings from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import CmdRef -from pyquickhelper.sphinxext.sphinx_cmdref_extension import cmdref_node, visit_cmdref_node, depart_cmdref_node +from pyquickhelper.sphinxext.sphinx_cmdref_extension import ( + cmdref_node, visit_cmdref_node, depart_cmdref_node) class TestMdBuilder(ExtTestCase): + @ignore_warnings(PendingDeprecationWarning) def test_md_builder(self): from docutils import nodes as skip_ @@ -34,8 +33,7 @@ def test_md_builder(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -79,6 +77,7 @@ def test_md_builder(self): if t1 in html: raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_md_builder_sphinx(self): from docutils import nodes as skip_ @@ -104,8 +103,7 @@ def test_md_builder_sphinx(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -138,6 +136,7 @@ def test_md_builder_sphinx(self): if t1 not in html: raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_md_builder_sphinx_table(self): from docutils import nodes as skip_ @@ -166,8 +165,7 @@ def test_md_builder_sphinx_table(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -196,6 +194,7 @@ def test_md_builder_sphinx_table(self): if len(spl) > 2: raise Exception(html) + @ignore_warnings(PendingDeprecationWarning) def test_md_only(self): from docutils import nodes as skip_ @@ -212,8 +211,7 @@ def test_md_only(self): only for md """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -248,6 +246,7 @@ def test_md_only(self): if t1 not in text: raise Exception(text) + @ignore_warnings(PendingDeprecationWarning) def test_md_reference(self): from docutils import nodes as skip_ @@ -259,8 +258,7 @@ def test_md_reference(self): :py:class:`Renamed ` """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -280,6 +278,7 @@ def test_md_reference(self): if t1 not in text: raise Exception(text) + @ignore_warnings(PendingDeprecationWarning) def test_md_reference2(self): from docutils import nodes as skip_ @@ -322,8 +321,7 @@ def test_md_reference2(self): jjjj """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="md", keep_warnings=False, layout='sphinx', @@ -340,6 +338,7 @@ def test_md_reference2(self): with open(os.path.join(temp, "out_cmdref.md"), "w", encoding="utf8") as f: f.write(text) + @ignore_warnings(PendingDeprecationWarning) def test_md_title(self): from docutils import nodes as skip_ @@ -358,8 +357,7 @@ def test_md_title(self): ****** """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="md", keep_warnings=False, layout='sphinx', @@ -373,6 +371,7 @@ def test_md_title(self): with open(os.path.join(temp, "out_md_title.md"), "w", encoding="utf8") as f: f.write(text) + @ignore_warnings(PendingDeprecationWarning) def test_md_image(self): temp = get_temp_folder(__file__, "temp_md_image") @@ -388,8 +387,7 @@ def test_md_image(self): :width: 200 :alt: alternative2 """.replace(" ", "").format(img1, img2).replace("\\", "/") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="md", keep_warnings=False, layout='sphinx', @@ -406,6 +404,7 @@ def test_md_image(self): with open(os.path.join(temp, "md_image.md"), "w", encoding="utf8") as f: f.write(text) + @ignore_warnings(PendingDeprecationWarning) def test_md_image_target(self): temp = get_temp_folder(__file__, "temp_md_image_target") @@ -417,8 +416,7 @@ def test_md_image_target(self): :width: 200 :alt: alternative1 """.replace(" ", "").format(img1).replace("\\", "/") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="md", keep_warnings=False, layout='sphinx', diff --git a/_unittests/ut_sphinxext/test_nbref_extension.py b/_unittests/ut_sphinxext/test_nbref_extension.py index bb295b76..75f562b3 100644 --- a/_unittests/ut_sphinxext/test_nbref_extension.py +++ b/_unittests/ut_sphinxext/test_nbref_extension.py @@ -2,36 +2,23 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest from docutils.parsers.rst import directives - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import NbRef, NbRefList -from pyquickhelper.sphinxext.sphinx_nbref_extension import nbref_node, visit_nbref_node, depart_nbref_node +from pyquickhelper.sphinxext.sphinx_nbref_extension import ( + nbref_node, visit_nbref_node, depart_nbref_node) -class TestNbRefExtension(unittest.TestCase): +class TestNbRefExtension(ExtTestCase): def test_post_parse_nbref(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("nbref", NbRef) directives.register_directive("nbreflist", NbRefList) def test_nbref(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -49,8 +36,7 @@ def test_nbref(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("nbref", NbRef, nbref_node, visit_nbref_node, depart_nbref_node)] @@ -76,11 +62,6 @@ def test_nbref(self): raise Exception(html) def test_nbreflist(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -104,8 +85,7 @@ def test_nbreflist(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("nbref", NbRef, nbref_node, visit_nbref_node, depart_nbref_node)] diff --git a/_unittests/ut_sphinxext/test_postcontents_extension.py b/_unittests/ut_sphinxext/test_postcontents_extension.py index 2d95141a..ffb93a7e 100644 --- a/_unittests/ut_sphinxext/test_postcontents_extension.py +++ b/_unittests/ut_sphinxext/test_postcontents_extension.py @@ -2,21 +2,17 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings from docutils.parsers.rst import directives - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import RunPythonDirective from pyquickhelper.sphinxext import PostContentsDirective -class TestPostContentsExtension(unittest.TestCase): +class TestPostContentsExtension(ExtTestCase): content = """ Contents: @@ -42,11 +38,6 @@ class TestPostContentsExtension(unittest.TestCase): """.replace(" ", "") def test_post_parse(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("runpython", RunPythonDirective) directives.register_directive("postcontents", PostContentsDirective) @@ -54,11 +45,6 @@ def test_contents(self): """ this test also test the extension runpython """ - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - content = TestPostContentsExtension.content rst = rst2html(content, # fLOG=fLOG, @@ -74,11 +60,6 @@ def test_postcontents(self): """ this test also test the extension runpython """ - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - content = TestPostContentsExtension.content.replace( "contents", "postcontents") diff --git a/_unittests/ut_sphinxext/test_quote_extension.py b/_unittests/ut_sphinxext/test_quote_extension.py index 3b0f54ab..49521460 100644 --- a/_unittests/ut_sphinxext/test_quote_extension.py +++ b/_unittests/ut_sphinxext/test_quote_extension.py @@ -2,20 +2,17 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest from docutils.parsers.rst import directives - -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import QuoteNode from pyquickhelper.sphinxext.sphinx_quote_extension import quote_node, visit_quote_node, depart_quote_node from pyquickhelper.sphinxext.sphinx_quote_extension import visit_quote_node_rst, depart_quote_node_rst -class TestMathDefExtension(unittest.TestCase): +class TestMathDefExtension(ExtTestCase): def test_post_parse_sn_todoext(self): directives.register_directive("quote", QuoteNode) @@ -35,8 +32,7 @@ def test_quote(self): next """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("quote", QuoteNode, quote_node, visit_quote_node, depart_quote_node)] @@ -98,8 +94,7 @@ def test_quote_manga(self): next """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("quote", QuoteNode, quote_node, visit_quote_node, depart_quote_node)] @@ -161,8 +156,7 @@ def test_quote_film(self): next """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("quote", QuoteNode, quote_node, visit_quote_node, depart_quote_node)] @@ -225,8 +219,7 @@ def test_quote_show(self): next """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("quote", QuoteNode, quote_node, visit_quote_node, depart_quote_node)] @@ -289,8 +282,7 @@ def test_quote_comic(self): next """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("quote", QuoteNode, quote_node, visit_quote_node, depart_quote_node)] @@ -353,8 +345,7 @@ def test_quote_disc(self): next """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("quote", QuoteNode, quote_node, visit_quote_node, depart_quote_node)] @@ -417,8 +408,7 @@ def test_quote_ado(self): next """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("quote", QuoteNode, quote_node, visit_quote_node, depart_quote_node)] @@ -481,8 +471,7 @@ def test_quote_child(self): next """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("quote", QuoteNode, quote_node, visit_quote_node, depart_quote_node)] diff --git a/_unittests/ut_sphinxext/test_revealsjs_directives.py b/_unittests/ut_sphinxext/test_revealsjs_directives.py index fd55c7f8..77ed5d7e 100644 --- a/_unittests/ut_sphinxext/test_revealsjs_directives.py +++ b/_unittests/ut_sphinxext/test_revealsjs_directives.py @@ -2,27 +2,17 @@ @brief test log(time=2s) @author Xavier Dupre """ - -import sys import os import unittest - -from pyquickhelper.sphinxext.revealjs.directives import heading -from pyquickhelper.sphinxext.revealjs.directives import RevealjsDirective -from pyquickhelper.sphinxext.revealjs.directives import RvNoteDirective -from pyquickhelper.sphinxext.revealjs.directives import RvSmallDirective -from pyquickhelper.sphinxext.revealjs.directives import RvCodeDirective -from pyquickhelper.sphinxext.revealjs.directives import visit_revealjs -from pyquickhelper.sphinxext.revealjs import compat -from pyquickhelper.sphinxext.revealjs.directives import depart_revealjs -from pyquickhelper.sphinxext.revealjs.directives import visit_rv_code -from pyquickhelper.sphinxext.revealjs.directives import depart_rv_code -from pyquickhelper.sphinxext.revealjs.directives import visit_rv_small -from pyquickhelper.sphinxext.revealjs.directives import depart_rv_small -from pyquickhelper.sphinxext.revealjs.directives import visit_rv_note -from pyquickhelper.sphinxext.revealjs.directives import depart_rv_note -from pyquickhelper.sphinxext.revealjs.directives import setup +from pyquickhelper.pycode import ExtTestCase +from pyquickhelper.sphinxext.revealjs.directives import ( + heading, RevealjsDirective, RvNoteDirective, RvSmallDirective, + RvCodeDirective, visit_revealjs, depart_revealjs, + visit_rv_code, depart_rv_code, visit_rv_small, + depart_rv_small, visit_rv_note, depart_rv_note, + setup) from pyquickhelper.sphinxext.revealjs import directives as d +from pyquickhelper.sphinxext.revealjs import compat class DummyConfig(object): @@ -42,7 +32,7 @@ def warning(self, msg, line): return dict(msg=msg, line=line) -class TestHeading(unittest.TestCase): +class TestHeading(ExtTestCase): def _get_target(self): return heading @@ -66,7 +56,7 @@ def test_value_error(self): pass -class TestRevealjsDirective(unittest.TestCase): +class TestRevealjsDirective(ExtTestCase): def _get_target_class(self): return RevealjsDirective @@ -80,6 +70,10 @@ def _get_dummy_config(self, **kwargs): return DummyConfig(**config) def _get_params(self, **kwargs): + from docutils.statemachine import State, StateMachine + stm = StateMachine([], None) + stm.reporter = None + st = State(stm) params = dict( name='dummyname', arguments=['tell-k', 'test'], @@ -88,8 +82,8 @@ def _get_params(self, **kwargs): lineno=1, content_offset=1, block_text="", - state="", - state_machine="", + state=st, + state_machine=stm, ) params.update(kwargs) return params @@ -129,7 +123,7 @@ def test_other_options(self): self.assertEqual("title-heading", nodes[0]['title-heading']) -class TestRvSmallDirective(unittest.TestCase): +class TestRvSmallDirective(ExtTestCase): def _get_target_class(self): return RvSmallDirective @@ -143,6 +137,10 @@ def _get_dummy_config(self, **kwargs): return DummyConfig(**config) def _get_params(self, **kwargs): + from docutils.statemachine import State, StateMachine + stm = StateMachine([], None) + stm.reporter = None + st = State(stm) params = dict( name='dummyname', arguments='', @@ -151,8 +149,8 @@ def _get_params(self, **kwargs): lineno=1, content_offset=1, block_text="", - state="", - state_machine="", + state=st, + state_machine=stm, ) params.update(kwargs) return params @@ -174,7 +172,7 @@ def test_class_option(self): self.assertEqual('add-class', nodes[0]['classes']) -class TestRvNoteDirective(unittest.TestCase): +class TestRvNoteDirective(ExtTestCase): def _get_target_class(self): return RvNoteDirective @@ -188,6 +186,10 @@ def _get_dummy_config(self, **kwargs): return DummyConfig(**config) def _get_params(self, **kwargs): + from docutils.statemachine import State, StateMachine + stm = StateMachine([], None) + stm.reporter = None + st = State(stm) params = dict( name='dummyname', arguments='', @@ -196,8 +198,8 @@ def _get_params(self, **kwargs): lineno=1, content_offset=1, block_text="", - state="", - state_machine="", + state=st, + state_machine=stm, ) params.update(kwargs) return params @@ -219,7 +221,7 @@ def test_class_option(self): assert 'add-class' == nodes[0]['classes'] -class TestRvCodeDirective(unittest.TestCase): +class TestRvCodeDirective(ExtTestCase): def _get_target_class(self): return RvCodeDirective @@ -233,6 +235,10 @@ def _get_dummy_config(self, **kwargs): return DummyConfig(**config) def _get_params(self, **kwargs): + from docutils.statemachine import State, StateMachine + stm = StateMachine([], None) + stm.reporter = None + st = State(stm) params = dict( name='dummyname', arguments='', @@ -241,8 +247,8 @@ def _get_params(self, **kwargs): lineno=1, content_offset=1, block_text="", - state="", - state_machine="", + state=st, + state_machine=stm, ) params.update(kwargs) return params @@ -255,7 +261,7 @@ def test_it(self): assert 1 == len(nodes) -class TestVisitRevealjs(unittest.TestCase): +class TestVisitRevealjs(ExtTestCase): def _get_target(self): return visit_revealjs @@ -355,7 +361,7 @@ def test_markdown(self): ], dummyself.body.content) -class TestDepartRevealjs(unittest.TestCase): +class TestDepartRevealjs(ExtTestCase): def _get_target(self): return depart_revealjs @@ -381,7 +387,7 @@ def test_it(self): assert '\n' == dummyself.body.content[0] -class TestVisitRvCode(unittest.TestCase): +class TestVisitRvCode(ExtTestCase): def _get_target(self): return visit_rv_code @@ -425,7 +431,7 @@ def test_it(self): assert 'rawsource' == dummyself.body.content[2] -class TestDepartRvCode(unittest.TestCase): +class TestDepartRvCode(ExtTestCase): def _get_target(self): return depart_rv_code @@ -453,7 +459,7 @@ def test_it(self): self.assertEqual('\n', dummyself.body.content[1]) -class TestVisitRvSmall(unittest.TestCase): +class TestVisitRvSmall(ExtTestCase): def _get_target(self): return visit_rv_small @@ -496,7 +502,7 @@ def test_it(self): assert True is dummyself.first_last -class TestDepartRvSmall(unittest.TestCase): +class TestDepartRvSmall(ExtTestCase): def _get_target(self): return depart_rv_small @@ -523,7 +529,7 @@ def test_it(self): assert '\n' == dummyself.body.content[0] -class TestVisitRvNote(unittest.TestCase): +class TestVisitRvNote(ExtTestCase): def _get_target(self): return visit_rv_note @@ -567,7 +573,7 @@ def test_it(self): assert True is dummyself.first_last -class TestDepartRvNote(unittest.TestCase): +class TestDepartRvNote(ExtTestCase): def _get_target(self): return depart_rv_note @@ -594,7 +600,7 @@ def test_it(self): self.assertEqual('\n', dummyself.body.content[0]) -class TestSetup(unittest.TestCase): +class TestSetup(ExtTestCase): def _get_target(self): return setup diff --git a/_unittests/ut_sphinxext/test_rst_builder.py b/_unittests/ut_sphinxext/test_rst_builder.py index 45f3f203..7e858484 100644 --- a/_unittests/ut_sphinxext/test_rst_builder.py +++ b/_unittests/ut_sphinxext/test_rst_builder.py @@ -4,11 +4,11 @@ """ import os import unittest -import sys from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import CmdRef -from pyquickhelper.sphinxext.sphinx_cmdref_extension import cmdref_node, visit_cmdref_node, depart_cmdref_node +from pyquickhelper.sphinxext.sphinx_cmdref_extension import ( + cmdref_node, visit_cmdref_node, depart_cmdref_node) from pyquickhelper.sphinxext.sphinximages.sphinxtrib.images import ImageDirective @@ -33,8 +33,7 @@ def test_rst_builder(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -99,8 +98,7 @@ def test_rst_builder_sphinx(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -161,8 +159,7 @@ def test_rst_builder_sphinx_table(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -203,8 +200,7 @@ def test_rst_only(self): only for rst """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -250,8 +246,7 @@ def test_rst_reference(self): :py:class:`Renamed ` """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("cmdref", CmdRef, cmdref_node, visit_cmdref_node, depart_cmdref_node)] @@ -324,8 +319,7 @@ def test_rst_reference2(self): jjjj """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="rst", keep_warnings=False, layout='sphinx', @@ -358,8 +352,7 @@ def test_rst_image(self): :alt: alternative2 :download: True """.replace(" ", "").format(img1, img2).replace("\\", "/") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("image", ImageDirective)] @@ -395,8 +388,7 @@ def test_rst_image_target(self): :width: 200 :alt: alternative1 """.replace(" ", "").format(img1).replace("\\", "/") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="rst", keep_warnings=False, layout='sphinx', @@ -420,8 +412,7 @@ def test_rst_image_target2(self): :width: 200 :alt: alternative1 """.replace(" ", "").format(img1).replace("\\", "/") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') text = rst2html(content, # fLOG=fLOG, writer="rst", keep_warnings=False, layout='sphinx', diff --git a/_unittests/ut_sphinxext/test_runpython_code_block.py b/_unittests/ut_sphinxext/test_runpython_code_block.py index eba11bcf..78ec98c3 100644 --- a/_unittests/ut_sphinxext/test_runpython_code_block.py +++ b/_unittests/ut_sphinxext/test_runpython_code_block.py @@ -2,13 +2,10 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings from docutils.parsers.rst import directives - from pyquickhelper.helpgen import rst2html from pyquickhelper.pycode import ExtTestCase from pyquickhelper.sphinxext.sphinx_runpython_extension import RunPythonDirective diff --git a/_unittests/ut_sphinxext/test_runpython_context.py b/_unittests/ut_sphinxext/test_runpython_context.py index c697c27a..9bca311c 100644 --- a/_unittests/ut_sphinxext/test_runpython_context.py +++ b/_unittests/ut_sphinxext/test_runpython_context.py @@ -2,13 +2,10 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings from docutils.parsers.rst import directives - from pyquickhelper.helpgen import rst2html from pyquickhelper.pycode import ExtTestCase from pyquickhelper.sphinxext.sphinx_runpython_extension import RunPythonDirective diff --git a/_unittests/ut_sphinxext/test_runpython_extension.py b/_unittests/ut_sphinxext/test_runpython_extension.py index eb18ad75..eb048bd6 100644 --- a/_unittests/ut_sphinxext/test_runpython_extension.py +++ b/_unittests/ut_sphinxext/test_runpython_extension.py @@ -2,38 +2,25 @@ @brief test log(time=4s) @author Xavier Dupre """ - import sys import os import unittest import warnings from docutils.parsers.rst import directives - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import RunPythonDirective -class TestRunPythonExtension(unittest.TestCase): +class TestRunPythonExtension(ExtTestCase): def test_post_parse(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("runpython", RunPythonDirective) def test_runpython(self): """ this test also test the extension runpython """ - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes class runpythonthis_node(nodes.Structural, nodes.Element): @@ -64,8 +51,7 @@ def depart_rp_node(self, node): import sys print(u"setsysvar: " + str(sys.__dict__.get('enable_disabled_documented_pieces_of_code', None))) """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node, visit_rp_node, depart_rp_node)] @@ -96,11 +82,6 @@ def test_runpython_numpy(self): """ this test also test the extension runpython """ - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes if "enable_disabled_documented_pieces_of_code" in sys.__dict__: @@ -129,11 +110,6 @@ def test_runpython_numpy_linenos(self): """ this test also test the extension runpython """ - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes if "enable_disabled_documented_pieces_of_code" in sys.__dict__: @@ -168,11 +144,6 @@ def test_runpython_catch_warning(self): """ this test also test the extension runpython """ - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes class runpythonthis_node(nodes.Structural, nodes.Element): @@ -203,8 +174,7 @@ def depart_rp_node(self, node): import warnings warnings.warn("deprecated", DeprecationWarning) """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node, visit_rp_node, depart_rp_node)] @@ -221,11 +191,6 @@ def test_runpython_notcatch_warning(self): """ this test also test the extension runpython """ - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes class runpythonthis_node(nodes.Structural, nodes.Element): @@ -255,8 +220,7 @@ def depart_rp_node(self, node): import warnings warnings.warn("deprecated", DeprecationWarning) """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node, visit_rp_node, depart_rp_node)] @@ -273,11 +237,6 @@ def test_runpython_raw(self): """ this test also test the extension runpython """ - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes class runpythonthis_node(nodes.Structural, nodes.Element): @@ -306,8 +265,7 @@ def depart_rp_node(self, node): import sys print(u"setsysvar: " + str(sys.__dict__.get('enable_disabled_documented_pieces_of_code', None))) """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node, visit_rp_node, depart_rp_node)] @@ -337,11 +295,6 @@ def test_runpython_process(self): """ this test also test the extension runpython """ - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes class runpythonthis_node(nodes.Structural, nodes.Element): @@ -373,8 +326,7 @@ def depart_rp_node(self, node): import sys print(u"setsysvar: " + str(sys.__dict__.get('enable_disabled_documented_pieces_of_code', None))) """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node, visit_rp_node, depart_rp_node)] @@ -401,11 +353,6 @@ def depart_rp_node(self, node): raise Exception("this case shoud not be") def test_runpython_exception(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes class runpythonthis_node(nodes.Structural, nodes.Element): @@ -435,8 +382,7 @@ def depart_rp_node(self, node): z = 1/0 print(u"this one should" + u" not") """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node, visit_rp_node, depart_rp_node)] @@ -458,11 +404,6 @@ def depart_rp_node(self, node): raise Exception(html) def test_runpython_exception_assert(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes class runpythonthis_node(nodes.Structural, nodes.Element): @@ -492,8 +433,7 @@ def depart_rp_node(self, node): z = 0.5 + 0.6 print(u"this one should" + u" not") """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node, visit_rp_node, depart_rp_node)] @@ -519,8 +459,7 @@ def depart_rp_node(self, node): z = 0.5 + 0.6 """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') try: html = rst2html(content, # fLOG=fLOG, @@ -531,11 +470,6 @@ def depart_rp_node(self, node): raise e def test_runpython_process_exception(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes class runpythonthis_node(nodes.Structural, nodes.Element): @@ -567,8 +501,7 @@ def depart_rp_node(self, node): z = 1/0 print(u"this one should" + u" not") """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node, visit_rp_node, depart_rp_node)] diff --git a/_unittests/ut_sphinxext/test_runpython_extension_image.py b/_unittests/ut_sphinxext/test_runpython_extension_image.py index a590e0b4..ff0e4bc1 100644 --- a/_unittests/ut_sphinxext/test_runpython_extension_image.py +++ b/_unittests/ut_sphinxext/test_runpython_extension_image.py @@ -7,8 +7,6 @@ import unittest import warnings from docutils.parsers.rst import directives - -from pyquickhelper.loghelper.flog import fLOG from pyquickhelper.pycode import get_temp_folder, ExtTestCase, skipif_azure_macosx from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import RunPythonDirective @@ -17,23 +15,14 @@ class TestRunPythonExtensionImage(ExtTestCase): def test_post_parse(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("runpython", RunPythonDirective) - @skipif_azure_macosx("Terminating app due to uncaught exception 'NSInvalidArgumentException'") + @skipif_azure_macosx("Terminating app due to uncaught exception " + "'NSInvalidArgumentException'") def test_runpython_image(self): """ this test also test the extension runpython """ - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes class runpythonthis_node(nodes.Structural, nodes.Element): @@ -71,8 +60,7 @@ def depart_rp_node(self, node): print(text) """.replace(" ", "").replace("__FOLD__", temp.replace("\\", "/")) - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node, visit_rp_node, depart_rp_node)] diff --git a/_unittests/ut_sphinxext/test_runpython_extension_toggle.py b/_unittests/ut_sphinxext/test_runpython_extension_toggle.py index 2da71f70..9a213ec9 100644 --- a/_unittests/ut_sphinxext/test_runpython_extension_toggle.py +++ b/_unittests/ut_sphinxext/test_runpython_extension_toggle.py @@ -2,38 +2,25 @@ @brief test log(time=4s) @author Xavier Dupre """ - import sys import os import unittest import warnings from docutils.parsers.rst import directives - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import RunPythonDirective -class TestRunPythonExtensionToggle(unittest.TestCase): +class TestRunPythonExtensionToggle(ExtTestCase): def test_post_parse(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("runpython", RunPythonDirective) def test_runpython_toggle(self): """ this test also test the extension runpython """ - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes class runpythonthis_node(nodes.Structural, nodes.Element): @@ -72,8 +59,7 @@ def depart_rp_node(self, node): import sys print(u"setsysvar: " + str(sys.__dict__.get('enable_disabled_documented_pieces_of_code', None))) """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node, visit_rp_node, depart_rp_node)] diff --git a/_unittests/ut_sphinxext/test_runpython_store_in_file.py b/_unittests/ut_sphinxext/test_runpython_store_in_file.py index cde29f83..4fbc4678 100644 --- a/_unittests/ut_sphinxext/test_runpython_store_in_file.py +++ b/_unittests/ut_sphinxext/test_runpython_store_in_file.py @@ -2,13 +2,10 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings from docutils.parsers.rst import directives - from pyquickhelper.helpgen import rst2html from pyquickhelper.pycode import ExtTestCase, get_temp_folder from pyquickhelper.sphinxext.sphinx_runpython_extension import RunPythonDirective diff --git a/_unittests/ut_sphinxext/test_sharenet_extension.py b/_unittests/ut_sphinxext/test_sharenet_extension.py index 85f78377..71cc966d 100644 --- a/_unittests/ut_sphinxext/test_sharenet_extension.py +++ b/_unittests/ut_sphinxext/test_sharenet_extension.py @@ -2,19 +2,16 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings from docutils.parsers.rst import directives - -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import ShareNetDirective -class TestShareNetExtension(unittest.TestCase): +class TestShareNetExtension(ExtTestCase): def test_post_parse_sn(self): directives.register_directive("sharenet", ShareNetDirective) @@ -36,8 +33,7 @@ def test_sharenet(self): this code shoud appear """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="html", keep_warnings=True, @@ -86,8 +82,7 @@ def test_sharenet_inline(self): abeforea :sharenet:`facebook-linkedin-twitter-20-body` aaftera """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="html", keep_warnings=True, @@ -128,8 +123,7 @@ def test_sharenet_inline_rst(self): abeforea :sharenet:`facebook-linkedin-twitter-30-body` aaftera """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="rst", keep_warnings=True, @@ -154,8 +148,7 @@ def test_sharenet_directive_rst(self): aaftera """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="rst", keep_warnings=True, diff --git a/_unittests/ut_sphinxext/test_simpleimage_extension.py b/_unittests/ut_sphinxext/test_simpleimage_extension.py index ca47a298..7cfd9665 100644 --- a/_unittests/ut_sphinxext/test_simpleimage_extension.py +++ b/_unittests/ut_sphinxext/test_simpleimage_extension.py @@ -2,7 +2,6 @@ @brief test log(time=6s) @author Xavier Dupre """ -import sys import os import unittest import warnings @@ -10,7 +9,8 @@ import shutil from io import StringIO from docutils.parsers.rst import directives -from pyquickhelper.pycode import get_temp_folder, ExtTestCase, is_travis_or_appveyor +from pyquickhelper.pycode import ( + get_temp_folder, ExtTestCase, is_travis_or_appveyor) from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import SimpleImageDirective from pyquickhelper.helpgen.sphinxm_custom_app import CustomSphinxApp @@ -46,8 +46,7 @@ def test_simpleimage(self): this code should appear """.replace(" ", "").format(img) - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') logger2 = logging.getLogger("video") diff --git a/_unittests/ut_sphinxext/test_style_doc.py b/_unittests/ut_sphinxext/test_style_doc.py index 57322e92..1083fc47 100644 --- a/_unittests/ut_sphinxext/test_style_doc.py +++ b/_unittests/ut_sphinxext/test_style_doc.py @@ -2,26 +2,20 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest - -from pyquickhelper.loghelper.flog import fLOG +from pyquickhelper.pycode import ExtTestCase from pyquickhelper.helpgen import rst2html -from pyquickhelper.sphinxext import get_default_extensions, get_default_standard_extensions +from pyquickhelper.sphinxext import ( + get_default_extensions, get_default_standard_extensions) from pyquickhelper.helpgen.utils_sphinx_doc import private_migrating_doxygen_doc -from pyquickhelper.helpgen._fake_function_to_documentation import f1, f2, f3, f4, f5, f6 +from pyquickhelper.helpgen._fake_function_to_documentation import ( + f1, f2, f3, f4, f5, f6) -class TestStyleDoc(unittest.TestCase): +class TestStyleDoc(ExtTestCase): def test_docstyle(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - extensions = get_default_standard_extensions() + get_default_extensions() extensions = [_ for _ in extensions if "matplotlib" not in _ and "images" not in _ and "IPython" not in _ and diff --git a/_unittests/ut_sphinxext/test_template_extension.py b/_unittests/ut_sphinxext/test_template_extension.py index 067945fa..651ea28e 100644 --- a/_unittests/ut_sphinxext/test_template_extension.py +++ b/_unittests/ut_sphinxext/test_template_extension.py @@ -2,19 +2,15 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import python_link_doc -class TestTemplateExtension(unittest.TestCase): +class TestTemplateExtension(ExtTestCase): def test_python_link_doc(self): link = python_link_doc("os") @@ -27,11 +23,6 @@ def test_python_link_doc(self): "`os.getcwd `_") def test_tpl_inline(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -40,8 +31,7 @@ def test_tpl_inline(self): abeforea :tpl:`onetmpl,p1='valstr',p2=4` aaftera """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="custom", keep_warnings=True, @@ -65,11 +55,6 @@ def test_tpl_inline(self): f.write(html) def test_tpl_inline_url(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -78,8 +63,7 @@ def test_tpl_inline_url(self): abeforea :tpl:`url,name='zoo',obj='boo'` aaftera """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="custom", keep_warnings=True, @@ -113,11 +97,6 @@ def test_tpl_inline_url(self): f.write(html) def test_tpl_inline_function(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -126,8 +105,7 @@ def test_tpl_inline_function(self): abeforea :tpl:`py,m='io'` aaftera """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') html = rst2html(content, # fLOG=fLOG, writer="custom", keep_warnings=True, diff --git a/_unittests/ut_sphinxext/test_thumbnail_extension.py b/_unittests/ut_sphinxext/test_thumbnail_extension.py index 10c3b7be..dbcb0c27 100644 --- a/_unittests/ut_sphinxext/test_thumbnail_extension.py +++ b/_unittests/ut_sphinxext/test_thumbnail_extension.py @@ -2,15 +2,12 @@ @brief test log(time=4s) @author Xavier Dupre """ -import sys import os import unittest import warnings import logging from io import StringIO from docutils.parsers.rst import directives - -from pyquickhelper.loghelper.flog import fLOG from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.helpgen.sphinxm_custom_app import CustomSphinxApp @@ -24,19 +21,9 @@ def setUp(self): logger.disabled = True def test_post_parse_sn(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("image", ImageDirective) def test_thumbnail(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -54,8 +41,7 @@ def test_thumbnail(self): this code shoud appear """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') logger2 = logging.getLogger("video") @@ -93,11 +79,6 @@ def test_thumbnail(self): f.write(html) def test_sphinx_ext_thumbnail_html(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - temp = get_temp_folder(__file__, "temp_sphinx_ext_thumbnail_html") src_ = os.path.join(temp, "..", "data", "image") diff --git a/_unittests/ut_sphinxext/test_tocdelay_extension.py b/_unittests/ut_sphinxext/test_tocdelay_extension.py index 39da0bc4..0099722e 100644 --- a/_unittests/ut_sphinxext/test_tocdelay_extension.py +++ b/_unittests/ut_sphinxext/test_tocdelay_extension.py @@ -2,19 +2,17 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import warnings from docutils.parsers.rst import directives from sphinx.errors import ExtensionError -from pyquickhelper.pycode import get_temp_folder, ignore_warnings +from pyquickhelper.pycode import get_temp_folder, ignore_warnings, ExtTestCase from pyquickhelper.helpgen import rst2html, rst2rst_folder from pyquickhelper.sphinxext import TocDelayDirective -class TestTocDelayExtension(unittest.TestCase): +class TestTocDelayExtension(ExtTestCase): def test_post_parse(self): directives.register_directive("tocdelay", TocDelayDirective) diff --git a/_unittests/ut_sphinxext/test_todoext_extension.py b/_unittests/ut_sphinxext/test_todoext_extension.py index 9373c2a6..0768a47e 100644 --- a/_unittests/ut_sphinxext/test_todoext_extension.py +++ b/_unittests/ut_sphinxext/test_todoext_extension.py @@ -2,36 +2,22 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest from docutils.parsers.rst import directives - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import TodoExt, TodoExtList from pyquickhelper.sphinxext.sphinx_todoext_extension import todoext_node, visit_todoext_node, depart_todoext_node -class TestTodoExtExtension(unittest.TestCase): +class TestTodoExtExtension(ExtTestCase): def test_post_parse_sn_todoext(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("todoext", TodoExt) directives.register_directive("todoextlist", TodoExtList) def test_todoext(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -49,8 +35,7 @@ def test_todoext(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("todoext", TodoExt, todoext_node, visit_todoext_node, depart_todoext_node)] @@ -83,11 +68,6 @@ def test_todoext(self): raise Exception(html) def test_todoextlist(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -107,8 +87,7 @@ def test_todoextlist(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("todoext", TodoExt, todoext_node, visit_todoext_node, depart_todoext_node)] @@ -138,11 +117,6 @@ def test_todoextlist(self): raise Exception(html) def test_todoext_done(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -161,8 +135,7 @@ def test_todoext_done(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("todoext", TodoExt, todoext_node, visit_todoext_node, depart_todoext_node)] diff --git a/_unittests/ut_sphinxext/test_video_extension.py b/_unittests/ut_sphinxext/test_video_extension.py index 448d57fe..8fb39ebf 100644 --- a/_unittests/ut_sphinxext/test_video_extension.py +++ b/_unittests/ut_sphinxext/test_video_extension.py @@ -2,7 +2,6 @@ @brief test log(time=4s) @author Xavier Dupre """ -import sys import os import unittest import warnings @@ -11,8 +10,6 @@ from platform import system from io import StringIO from docutils.parsers.rst import directives - -from pyquickhelper.loghelper.flog import fLOG from pyquickhelper.pycode import get_temp_folder, ExtTestCase, is_travis_or_appveyor from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import VideoDirective @@ -28,20 +25,10 @@ def setUp(self): logger.disabled = True def test_post_parse_sn(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("video", VideoDirective) @unittest.skipIf(system() == "Darwin", reason="no end") def test_video(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -58,8 +45,7 @@ def test_video(self): this code shoud appear """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') logger2 = logging.getLogger("video") @@ -116,11 +102,6 @@ def setup_format(self, temp): @unittest.skipIf(system() == "Darwin", reason="no end") def test_sphinx_ext_video_html(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - temp = get_temp_folder(__file__, "temp_sphinx_ext_video_html") src_ = self.setup_format(temp) @@ -141,11 +122,6 @@ def test_sphinx_ext_video_html(self): @unittest.skipIf(system() == "Darwin", reason="no end") def test_sphinx_ext_video_rst(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - temp = get_temp_folder(__file__, "temp_sphinx_ext_video_rst") src_ = self.setup_format(temp) @@ -167,19 +143,11 @@ def test_sphinx_ext_video_rst(self): @unittest.skipIf(system() == "Darwin", reason="no end") def test_sphinx_ext_video_latex(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - temp = get_temp_folder(__file__, "temp_sphinx_ext_video_latex") - fLOG('custom app init') src_ = self.setup_format(temp) app = CustomSphinxApp(src_, temp, buildername="latex") - fLOG('custom app build') app.build() - fLOG('custom app done') index = os.path.join(temp, "pyq-video.tex") self.assertExists(index) @@ -196,19 +164,12 @@ def test_sphinx_ext_video_latex(self): if is_travis_or_appveyor() not in ('travis', 'appveyor'): latex = find_latex_path() - fLOG("latex-compile", latex) compile_latex_output_final(temp, latex, doall=True) - fLOG("compilatione done") index = os.path.join(temp, "pyq-video.pdf") self.assertExists(index) @unittest.skipIf(system() == "Darwin", reason="no end") def test_sphinx_ext_video_text(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - temp = get_temp_folder(__file__, "temp_sphinx_ext_video_text") src_ = self.setup_format(temp) app = CustomSphinxApp(src_, temp, buildername="text") @@ -229,11 +190,6 @@ def test_sphinx_ext_video_text(self): @unittest.skipIf(system() == "Darwin", reason="no end") def test_video_url(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -249,8 +205,7 @@ def test_video_url(self): this code shoud appear """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') logger2 = logging.getLogger("video") diff --git a/_unittests/ut_sphinxext/test_youtube_extension.py b/_unittests/ut_sphinxext/test_youtube_extension.py index 1ea3a3d3..35b49736 100644 --- a/_unittests/ut_sphinxext/test_youtube_extension.py +++ b/_unittests/ut_sphinxext/test_youtube_extension.py @@ -2,38 +2,24 @@ @brief test log(time=4s) @author Xavier Dupre """ - -import sys import os import unittest import logging from io import StringIO from docutils.parsers.rst import directives from sphinx.util.logging import getLogger - -from pyquickhelper.loghelper.flog import fLOG -from pyquickhelper.pycode import get_temp_folder +from pyquickhelper.pycode import get_temp_folder, ExtTestCase from pyquickhelper.helpgen import rst2html from pyquickhelper.sphinxext import YoutubeDirective from pyquickhelper.sphinxext.sphinx_youtube_extension import youtube_node, visit_youtube_node, depart_youtube_node -class TestYoutubeExtension(unittest.TestCase): +class TestYoutubeExtension(ExtTestCase): def test_post_parse_sn_youtube(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - directives.register_directive("youtube", YoutubeDirective) def test_youtube(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -48,8 +34,7 @@ def test_youtube(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("youtube", YoutubeDirective, youtube_node, visit_youtube_node, depart_youtube_node)] @@ -78,11 +63,6 @@ def test_youtube(self): raise Exception(html) def test_youtube_size(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -98,8 +78,7 @@ def test_youtube_size(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("youtube", YoutubeDirective, youtube_node, visit_youtube_node, depart_youtube_node)] @@ -128,11 +107,6 @@ def test_youtube_size(self): raise Exception(html) def test_youtube_size_nowarning(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") - from docutils import nodes as skip_ content = """ @@ -148,8 +122,7 @@ def test_youtube_size_nowarning(self): after """.replace(" ", "") - if sys.version_info[0] >= 3: - content = content.replace('u"', '"') + content = content.replace('u"', '"') tives = [("youtube", YoutubeDirective, youtube_node, visit_youtube_node, depart_youtube_node)] @@ -165,11 +138,6 @@ def test_youtube_size_nowarning(self): self.assertIn('