Skip to content

Commit

Permalink
test: remove console color and style rendering during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
u8slvn committed Jul 15, 2022
1 parent e61f269 commit 0ca22ea
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ celerybeat.pid
*.sage.py

# Environments
.env
.test.env
.venv
env/
venv/
Expand Down
1 change: 1 addition & 0 deletions .test.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TERM=dumb
2 changes: 1 addition & 1 deletion hyperfocus/termui/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from hyperfocus.termui import formatter, icons


console = Console(highlight=False)
console = Console(highlight=False, force_terminal=True)


def echo(text: str):
Expand Down
27 changes: 26 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ mypy = ">=0.961"
freezegun = "^1.2.1"
types-tabulate = "^0.8.11"
pre-commit = "^2.6"
pytest-dotenv = "^0.5.2"

[tool.poetry.scripts]
hyf = "hyperfocus.cli:hyf"
Expand All @@ -57,3 +58,7 @@ src_paths = ["hyperfocus", "tests"]
module=["peewee", "pyperclip"]
warn_unused_ignores = false
ignore_missing_imports = true

[tool.pytest.ini_options]
env_override_existing_values = 1
env_files = [".test.env"]
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import os
import re
import shutil
from pathlib import Path
Expand Down Expand Up @@ -70,3 +71,10 @@ def __init__(self):
self._callback_commands = []

return MockSession()


@pytest.fixture(scope="session", autouse=True)
def no_color():
os.environ["TERM"] = "dumb"
yield
del os.environ["TERM"]
4 changes: 2 additions & 2 deletions tests/test_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
@pytest.mark.parametrize(
"func, expected",
[
("banner", "\x1b[3;38;5;228mfoobar\x1b[0m\n"),
("new_day", f"{icons.NEW_DAY} \x1b[38;5;81mfoobar\x1b[0m\n"),
("banner", "foobar\n"),
("new_day", f"{icons.NEW_DAY} foobar\n"),
],
)
def test_banner(capsys, func, expected):
Expand Down

0 comments on commit 0ca22ea

Please sign in to comment.