Skip to content

Commit

Permalink
Use to_str() instead of print for tests because gh actions
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonscript committed Mar 19, 2024
1 parent 762511b commit 4e3feee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Test with pytest
run: |
pip install pytest
pytest -xv --capture=tee-sys
pytest -xv -s
build-newer-python:
runs-on: ubuntu-22.04
Expand All @@ -54,4 +54,4 @@ jobs:
- name: Test with pytest
run: |
pip install pytest
pytest -xv --capture=tee-sys
pytest -xv -s
21 changes: 8 additions & 13 deletions tests/test_tinta.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from typing import List, Tuple

import pytest
from pytest import CaptureFixture

# pylint: disable=import-error
from tinta import Tinta
Expand Down Expand Up @@ -93,24 +92,20 @@ def assert_its_not_easy_being_green(self, out: str):
assert self.ITS_NOT_EASY in out
assert "\x1b[38;5;35m" in out

def test_tint_takes_int_arg0_as_color(self, capfd: CaptureFixture[str]):
Tinta().tint(35, self.ITS_NOT_EASY).print()
out = capfd.readouterr().out
def test_tint_takes_int_arg0_as_color(self):
out = Tinta().tint(35, self.ITS_NOT_EASY).to_str()
self.assert_its_not_easy_being_green(out)

def test_tint_takes_str_arg0_as_color(self, capfd: CaptureFixture[str]):
Tinta().tint("green", self.ITS_NOT_EASY).print()
out = capfd.readouterr().out
def test_tint_takes_str_arg0_as_color(self):
out = Tinta().tint("green", self.ITS_NOT_EASY).to_str()
self.assert_its_not_easy_being_green(out)

def test_tint_takes_int_color_kwarg(self, capfd: CaptureFixture[str]):
Tinta().tint(self.ITS_NOT_EASY, color=35).print()
out = capfd.readouterr().out
def test_tint_takes_int_color_kwarg(self):
out = Tinta().tint(self.ITS_NOT_EASY, color=35).to_str()
self.assert_its_not_easy_being_green(out)

def test_tint_takes_str_color_kwarg(self, capfd: CaptureFixture[str]):
Tinta().tint(self.ITS_NOT_EASY, color="green").print()
out = capfd.readouterr().out
def test_tint_takes_str_color_kwarg(self):
out = Tinta().tint(self.ITS_NOT_EASY, color="green").to_str()
self.assert_its_not_easy_being_green(out)


Expand Down

0 comments on commit 4e3feee

Please sign in to comment.