-
-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix relative paths for SVG files stored as data URLs
Fix #1641.
- Loading branch information
Showing
2 changed files
with
43 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,51 @@ | ||
"""Test how SVG definitions are drawn.""" | ||
|
||
from base64 import b64encode | ||
|
||
from ...testing_utils import assert_no_logs | ||
from .. import assert_pixels | ||
|
||
SVG = ''' | ||
<svg width="10px" height="10px" xmlns="http://www.w3.org/2000/svg"> | ||
<defs> | ||
<rect id="rectangle" width="5" height="2" fill="red" /> | ||
</defs> | ||
<use href="#rectangle" /> | ||
<use href="#rectangle" x="3" y="3" /> | ||
<use href="#rectangle" x="5" y="6" /> | ||
</svg> | ||
''' | ||
|
||
RESULT = ''' | ||
RRRRR_____ | ||
RRRRR_____ | ||
__________ | ||
___RRRRR__ | ||
___RRRRR__ | ||
__________ | ||
_____RRRRR | ||
_____RRRRR | ||
__________ | ||
__________ | ||
''' | ||
|
||
|
||
@assert_no_logs | ||
def test_use(): | ||
assert_pixels('use', 10, 10, ''' | ||
RRRRR_____ | ||
RRRRR_____ | ||
__________ | ||
___RRRRR__ | ||
___RRRRR__ | ||
__________ | ||
_____RRRRR | ||
_____RRRRR | ||
__________ | ||
__________ | ||
''', ''' | ||
assert_pixels('use', 10, 10, RESULT, ''' | ||
<style> | ||
@page { size: 10px } | ||
svg { display: block } | ||
</style> | ||
<svg width="10px" height="10px" xmlns="http://www.w3.org/2000/svg" | ||
xlink="http://www.w3.org/1999/xlink"> | ||
<defs> | ||
<rect id="rectangle" width="5" height="2" fill="red" /> | ||
</defs> | ||
<use xlink:href="#rectangle" /> | ||
<use xlink:href="#rectangle" x="3" y="3" /> | ||
<use xlink:href="#rectangle" x="5" y="6" /> | ||
</svg> | ||
''') | ||
''' + SVG) | ||
|
||
|
||
@assert_no_logs | ||
def test_use_base64(): | ||
base64_svg = b64encode(SVG.encode()).decode() | ||
assert_pixels('use_base64', 10, 10, RESULT, ''' | ||
<style> | ||
@page { size: 10px } | ||
img { display: block } | ||
</style> | ||
<img src="data:image/svg+xml;base64,''' + base64_svg + '"/>') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters