def test_add_or_replace():
    'Test replacing existing figures in a report.'
    r = Report()
    (fig1, fig2) = _get_example_figures()
    r.add_figs_to_section(fig1, 'duplicate', 'mysection')
    r.add_figs_to_section(fig1, 'duplicate', 'mysection')
    r.add_figs_to_section(fig1, 'duplicate', 'othersection')
    r.add_figs_to_section(fig2, 'nonduplicate', 'mysection')
    assert (len(r.html) == 4)
    old_r = copy.deepcopy(r)
    r.add_figs_to_section(fig2, 'duplicate', 'mysection', replace=True)
    assert (len(r.html) == 4)
    assert (r.html[1] != old_r.html[1])
    assert (r.html[0] == old_r.html[0])
    assert (r.html[2] == old_r.html[2])
    assert (r.html[3] == old_r.html[3])
Test replacing existing figures in a report.
def test_add_or_replace():
    
    r = Report()
    (fig1, fig2) = _get_example_figures()
    r.add_figs_to_section(fig1, 'duplicate', 'mysection')
    r.add_figs_to_section(fig1, 'duplicate', 'mysection')
    r.add_figs_to_section(fig1, 'duplicate', 'othersection')
    r.add_figs_to_section(fig2, 'nonduplicate', 'mysection')
    assert (len(r.html) == 4)
    old_r = copy.deepcopy(r)
    r.add_figs_to_section(fig2, 'duplicate', 'mysection', replace=True)
    assert (len(r.html) == 4)
    assert (r.html[1] != old_r.html[1])
    assert (r.html[0] == old_r.html[0])
    assert (r.html[2] == old_r.html[2])
    assert (r.html[3] == old_r.html[3])