Closed ssjkamei closed 1 month ago
It seems difficult to obtain the actual font size etc.
Could you please elaborate?
Is it necessary to test?
Yes, in the best case we would check the correct output here as well covering some common combinations.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 96.43%. Comparing base (
96b46ad
) to head (423876d
). Report is 1 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
It seems difficult to obtain the actual font size etc.
Could you please elaborate?
The problem is that it's difficult for me to capture in code that the font size has changed. There was originally a test that asked you to see it with your own eyes, but is there any problem with this?
def test_free_text_annotation(pdf_file_path):
# Arrange
pdf_path = RESOURCE_ROOT / "crazyones.pdf"
reader = PdfReader(pdf_path)
page = reader.pages[0]
writer = PdfWriter()
writer.add_page(page)
# Act
free_text_annotation = FreeText(
text="Hello World - bold and italic\nThis is the second line!",
rect=(50, 550, 200, 650),
font="Arial",
bold=True,
italic=True,
font_size="20pt",
font_color="00ff00",
border_color=None,
background_color=None,
)
writer.add_annotation(0, free_text_annotation)
free_text_annotation = FreeText(
text="Another free text annotation (not bold, not italic)",
rect=(500, 550, 200, 650),
font="Arial",
bold=False,
italic=False,
font_size="20pt",
font_color="00ff00",
border_color="0000ff",
background_color="cdcdcd",
)
writer.add_annotation(0, free_text_annotation)
# Assert: You need to inspect the file manually
with open(pdf_file_path, "wb") as fp:
writer.write(fp)
In general, we prefer tests that are automated. Thus, for your change, I would prefer you to add a corresponding test which asserts that we indeed generate the correct font strings from the inputs. IMHO this case can be tested from code and does not need manual inspection.
Is it okay to delete the original test and create a new one? In this case, as a test, do you mean read it with PDFReader after writing and check the input value as is? Do you have any hints?
It should not harm to keep the existing test nevertheless.
In my opinion, it would be sufficient to just create different FreeText
instances and verify their /DS
entry using assert "abc" == FreeText()["/DS"]
.
Thank you! I've added this to the existing test, is this correct?
I think #2305 can be closed if there are no problems with the comments.
I've added this to the existing test, is this correct?
Please move this to a dedicated test function, for example test_free_text_annotation__font_specifier
or similar.
I changed it. Please help me if there are any problems with the input location. Sorry for repeating the basic points. Thank you.
@stefan6419846 Please also check the following two issues.
Close #1435
The order of the list was different.
It seems difficult to obtain the actual font size etc. Is it necessary to test?