def test_thumbnail_div(): """Test if the thumbnail div generates the correct string""" with pytest.raises(RuntimeError, match='internal sphinx-gallery thumb'): html_div = sg._thumbnail_div('fake_dir', '', 'test_file.py', '<"test">') html_div = sg._thumbnail_div('fake_dir', '', 'test_file.py', '<"test">', check=False) reference = r""" .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="<"test">"> .. only:: html .. figure:: /fake_dir/images/thumb/sphx_glr_test_file_thumb.png :ref:`sphx_glr_fake_dir_test_file.py` .. raw:: html </div> """ assert html_div == reference
def test_backref_thumbnail_div(): """Test if the thumbnail div generates the correct string""" html_div = sg._thumbnail_div('fake_dir', 'test_file.py', 'test formating', is_backref=True) reference = """ .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="test formating"> .. only:: html .. figure:: /fake_dir/images/thumb/sphx_glr_test_file_thumb.png :ref:`sphx_glr_fake_dir_test_file.py` .. raw:: html </div> .. only:: not html * :ref:`sphx_glr_fake_dir_test_file.py` """ assert html_div == reference
def test_backref_thumbnail_div(): """Test if the thumbnail div generates the correct string""" html_div = sg._thumbnail_div('fake_dir', '', 'test_file.py', 'test formating', is_backref=True, check=False) reference = """ .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="test formating"> .. only:: html .. figure:: /fake_dir/images/thumb/sphx_glr_test_file_thumb.png :ref:`sphx_glr_fake_dir_test_file.py` .. raw:: html </div> .. only:: not html * :ref:`sphx_glr_fake_dir_test_file.py` """ assert html_div == reference
def test_backref_thumbnail_div(): """Test if the thumbnail div generates the correct string""" html_div = sg._thumbnail_div('fake_dir', 'test_file.py', 'test formating', is_backref=True) reference = """ .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="test formating"> .. only:: html .. figure:: /fake_dir{0}images{0}thumb{0}sphx_glr_test_file_thumb.png :ref:`sphx_glr_fake_dir_test_file.py` .. raw:: html </div> .. only:: not html * :ref:`sphx_glr_fake_dir_test_file.py` """.format(os.sep) assert_equal(html_div, reference)
def test_thumbnail_div(content, tooltip, is_backref): """Test if the thumbnail div generates the correct string.""" with pytest.raises(RuntimeError, match='internal sphinx-gallery thumb'): html_div = sg._thumbnail_div('fake_dir', '', 'test_file.py', '<"test">') content = _sanitize_rst(content) html_div = sg._thumbnail_div('fake_dir', '', 'test_file.py', content, is_backref=is_backref, check=False) if is_backref: extra = """ .. only:: not html * :ref:`sphx_glr_fake_dir_test_file.py`""" else: extra = '' reference = REFERENCE.format(tooltip, extra) assert html_div == reference
def test_thumbnail_div(): """Test if the thumbnail div generates the correct string""" html_div = sg._thumbnail_div('fake_dir', 'test_file.py', '<"test">') reference = r""" .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="<"test">"> .. only:: html .. figure:: /fake_dir/images/thumb/sphx_glr_test_file_thumb.png :ref:`sphx_glr_fake_dir_test_file.py` .. raw:: html </div> """ assert html_div == reference
def test_thumbnail_div(): """Test if the thumbnail div generates the correct string""" html_div = sg._thumbnail_div('fake_dir', 'test_file.py', 'test formating') reference = """ .. raw:: html <div class="sphx-glr-thumbContainer" tooltip="test formating"> .. only:: html .. figure:: /fake_dir/images/thumb/sphx_glr_test_file_thumb.png :ref:`sphx_glr_fake_dir_test_file.py` .. raw:: html </div> """ assert_equal(html_div, reference)
def test_thumbnail_div(): """Test if the thumbnail div generates the correct string""" html_div = sg._thumbnail_div('fake_dir', 'test_file.py', 'test formating') reference = """ .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="test formating"> .. only:: html .. figure:: /fake_dir/images/thumb/sphx_glr_test_file_thumb.png :ref:`sphx_glr_fake_dir_test_file.py` .. raw:: html </div> """ assert_equal(html_div, reference)