From 393aa58f2c5afd51f92fd9bd4b6dfd0dc90cea41 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Fri, 5 Aug 2022 01:00:19 -0400 Subject: New upstream version 8.2.3. --- tests/test_compile_markdown.py | 10 ++++------ tests/test_rst_compiler.py | 23 +++++++++++++++++++++++ tests/test_utils.py | 26 ++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/test_compile_markdown.py b/tests/test_compile_markdown.py index 0e805ba..a902347 100644 --- a/tests/test_compile_markdown.py +++ b/tests/test_compile_markdown.py @@ -28,12 +28,10 @@ from .helper import FakeSite from this """, """\ -
\ -
1
\ -
\
-from this
-
-
+
\ +
\ +from this +
""", id="hilite", ), diff --git a/tests/test_rst_compiler.py b/tests/test_rst_compiler.py index 803fd79..88638f7 100644 --- a/tests/test_rst_compiler.py +++ b/tests/test_rst_compiler.py @@ -87,6 +87,29 @@ def test_youtube_iframe(): ) +def test_youtube_iframe_start_at(): + """Test Youtube iframe tag generation with start_at attribute""" + + sample = ".. youtube:: YID\n :height: 400\n :width: 600\n :start_at: 60" + html = get_html_from_rst(sample) + assert_html_contains( + html, + "iframe", + attributes={ + "src": ( + "https://www.youtube-nocookie.com" + "/embed/YID?rel=0&" + "wmode=transparent&start=60" + ), + "height": "400", + "width": "600", + "frameborder": "0", + "allowfullscreen": "", + "allow": "encrypted-media", + }, + ) + + def test_vimeo(disable_vimeo_api_query): """Test Vimeo iframe tag generation""" diff --git a/tests/test_utils.py b/tests/test_utils.py index 1996679..764eec2 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -14,13 +14,16 @@ from nikola.post import get_meta from nikola.utils import ( TemplateHookRegistry, TranslatableSetting, + NikolaPygmentsHTML, demote_headers, get_asset_path, get_crumbs, get_theme_chain, get_translation_candidate, + nikola_find_formatter_class, write_metadata, bool_from_meta, + parselinenos ) @@ -619,3 +622,26 @@ class FakePost: def __init__(self): metadata_extractors.load_defaults(self, self.metadata_extractors_by) + + +def test_parselinenos(): + assert parselinenos('1,2,3', 10) == [0, 1, 2] + assert parselinenos('4, 5, 6', 10) == [3, 4, 5] + assert parselinenos('-4', 10) == [0, 1, 2, 3] + assert parselinenos('7-9', 10) == [6, 7, 8] + assert parselinenos('7-', 10) == [6, 7, 8, 9] + assert parselinenos('1,7-', 10) == [0, 6, 7, 8, 9] + assert parselinenos('7-7', 10) == [6] + assert parselinenos('11-', 10) == [10] + with pytest.raises(ValueError): + parselinenos('1-2-3', 10) + with pytest.raises(ValueError): + parselinenos('abc-def', 10) + with pytest.raises(ValueError): + parselinenos('-', 10) + with pytest.raises(ValueError): + parselinenos('3-1', 10) + + +def test_nikola_find_formatter_class_returns_pygments_class(): + assert NikolaPygmentsHTML == nikola_find_formatter_class("html") -- cgit v1.2.3