-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase test coverage for fpdf.py #439
Conversation
Codecov Report
@@ Coverage Diff @@
## master #439 +/- ##
==========================================
+ Coverage 91.55% 91.88% +0.32%
==========================================
Files 22 22
Lines 6408 6408
Branches 1290 1290
==========================================
+ Hits 5867 5888 +21
+ Misses 311 298 -13
+ Partials 230 222 -8
Continue to review full report at Codecov.
|
Interesting. I think PyFPDF/fpdf2 used to support embedding images with indexed colors but the current code forces a conversion to RGB.
I think ideally we should not force conversion to RGB and allow users to embed indexed images, as the PDF spec permits it.
Interesting again. Could that case be for "core" fonts? cf. https://github.com/PyFPDF/fpdf2/blob/2.5.4/fpdf/fpdf.py#L1734 After digging a little more in the code history, I found out that valid values for I don't think that's possible anymore. Also, given our current plan in #418, I'm not sure it's really worth improving that part of the code, regarding clarity & coverage. |
Thank you for the fast and thoroughly reply!
I would like to see if I can insert this feature. It seems that the code is already there. I will try to make a new PR that implements it along with some tests For the fonts parts I would like to get into them after the palette matter |
Oh I see, so I agree with you, I think it's worth more focusing on the switch to using For me this PR is concluded, it's up to you if you want to merge the unit tests I made here 😊 |
Merged! |
I wrote some test to increase coverage for the file fpdf.py - #395
I wanted to write more but I encountered two problems:
._putimage()
, at line 3951 and 3994, in the context of image info, I see that the branch true ofif info["cs"] == "Indexed":
is not tested. I tried to make a test that follows the true branch, but I always seeinfo["cs"] = "DeviceRGB"
. Then I see that in the moduleimage_parsing
there isn't the value"Indexed"
, but only"DeviceRGB"
and"DeviceGray"
. So I conclude thatif info["cs"] == "Indexed":
cannot be ever accessed, maybe I'm missing something?._putfonts()
, at line 3613, the branch true ofif "type" in info and info["type"] != "TTF":
is not tested. I tried to see which formats are supported other than"TTF"
and I see that in the methodadd_font()
, at line 1626, I seeif ext not in (".otf", ".otc", ".ttf", ".ttc"):
. I tried to open otf and ttc fonts but both seems not supported. Any suggestion to test this branch?Checklist:
The GitHub pipeline is OK (green),
meaning that both
pylint
(static code analyzer) andblack
(code formatter) are happy with the changes of this PR.A unit test is covering the code added / modified by this PR
This PR is ready to be merged
In case of a new feature, docstrings have been added, with also some documentation in the
docs/
folderA mention of the change is present in
CHANGELOG.md