Skip to content

Commit

Permalink
优化测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
TakWolf committed Jul 9, 2024
1 parent 1f62e8c commit 602b567
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tests/test_glyph_file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_glyph_file_1():

def test_glyph_file_2():
with pytest.raises(ValueError) as info:
glyph_file = GlyphFile.load(Path('notdef a,b.png'))
GlyphFile.load(Path('notdef a,b.png'))
assert info.value.args[0] == "'notdef' can't have flavors: 'notdef a,b.png'"


Expand All @@ -29,7 +29,7 @@ def test_glyph_file_3():


def test_glyph_file_4():
glyph_file = GlyphFile.load(Path('4E00 a,b,c,b,a.png'))
glyph_file = GlyphFile.load(Path('4E00 A,b,C,b,a.png'))
assert glyph_file.code_point == 0x4E00
assert glyph_file.flavors == ['a', 'b', 'c']
assert glyph_file.glyph_name == '4E00-A'
Expand Down
9 changes: 2 additions & 7 deletions tests/test_mono_bitmap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import hashlib
from io import BytesIO
from pathlib import Path

Expand All @@ -7,10 +6,6 @@
from pixel_font_knife.mono_bitmap import MonoBitmap


def _sha256(data: bytes) -> str:
return hashlib.sha256(data).hexdigest()


def test_init():
bitmap = MonoBitmap([
[0, 1, 2, 3],
Expand Down Expand Up @@ -235,13 +230,13 @@ def test_load_dump_save(glyphs_dir: Path, tmp_path: Path):
black_bitmap.save_png(black_save_path)
black_stream = BytesIO()
black_bitmap.dump_png(black_stream)
assert _sha256(black_load_path.read_bytes()) == _sha256(black_save_path.read_bytes()) == _sha256(black_stream.getvalue())
assert black_load_path.read_bytes() == black_save_path.read_bytes() == black_stream.getvalue()

red_save_path = red_save_dir.joinpath(red_load_path.name)
red_bitmap.save_png(red_save_path, color=(255, 0, 0))
red_stream = BytesIO()
red_bitmap.dump_png(red_stream, color=(255, 0, 0))
assert _sha256(red_load_path.read_bytes()) == _sha256(red_save_path.read_bytes()) == _sha256(red_stream.getvalue())
assert red_load_path.read_bytes() == red_save_path.read_bytes() == red_stream.getvalue()


def test_bold_s4_r1_e1(glyphs_dir: Path):
Expand Down

0 comments on commit 602b567

Please sign in to comment.