Skip to content

Commit

Permalink
Fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Oct 28, 2024
1 parent 5fc78ae commit 62d2151
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
27 changes: 0 additions & 27 deletions src/textual/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,33 +584,6 @@ def lighten(self, amount: float, alpha: float | None = None) -> Color:
"""
return self.darken(-amount, alpha)

@lru_cache(maxsize=1024)
def tint(self, color: Color) -> Color:
"""Apply a tint to a color.
Similar to blend, but preserves the alpha of the original.
Args:
color: A color with alpha component.
Returns:
New color
"""
if color.ansi is not None:
return color
r2, g2, b2, a2, _ = color
if a2 <= 0:
return self
if a2 >= 1:
return color
r1, g1, b1, a1, _ = self
return Color(
int(r1 * a1 + (r2 - r1) * a2),
int(g1 * a1 + (g2 - g1) * a2),
int(b1 * a1 + (b2 - b1) * a2),
max(1.0, a1 + a2),
)

@lru_cache(maxsize=1024)
def get_contrast_text(self, alpha: float = 0.95) -> Color:
"""Get a light or dark color that best contrasts this color, for use with text.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,5 @@ def on_markdown_link_clicked(self, message: Markdown.LinkClicked):

app = MyApp()
async with app.run_test() as pilot:
await pilot.click(Markdown, offset=(0, 0))
await pilot.click(Markdown, offset=(3, 0))
assert links == ["tété"]

0 comments on commit 62d2151

Please sign in to comment.