Make term-img easier to unit test
See original GitHub issueIs your feature request related to a problem? Please describe.
I’m having trouble actually using term-img when running unit tests, because term_img.exceptions.InvalidSize is raised when TermImage
is initialized.
Describe the solution you’d like
I’m not sure what’s best here, but one quick solution would be add check_width
and check_height
args to TermImage
, so that they can be passed to set_size
here
Overall, I’m also wondering if the size shouldn’t be validated at __init__
? Might be more appropriate to evaluate at draw()
time only.
Describe alternatives you’ve considered
I could just mock get_terminal_size
to give me the size I’m trying to emulate in my tests as a fallback, but wondering if the library itself could use some way to control this.
Additional context
Just wanted to say that I’ve really enjoyed using this library, and want to make it the default image renderer in a cli I’m working on. Appreciate the work here!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:14 (11 by maintainers)
Top GitHub Comments
You’d be right.
Really looking forward to seeing this developing. Will be following closely. Of course, no rush! Really happy already with how the renders turned out.
Yeah I saw that! I don’t see this leveraged a lot so I thought this was an interesting API design!
I noticed you’re using
str(block_image)
, you can control the alignment (amongst other things) using any string formatting method with theTermImage
instance e.gto always have the images centered within the available space i.e
(max_width, max_height)
.See here for more.