Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mzaatar committed Dec 30, 2022
1 parent 83e3891 commit 4500362
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions tests/bootstrap/test_bootstrap_env.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
import click
from _pytest.tmpdir import TempPathFactory
from approvaltests.scrubbers.scrubbers import Scrubber
from prompt_toolkit.input import PipeInput
from utils.approvals import verify
from utils.approvals import TokenScrubber, combine_scrubbers, verify
from utils.click_invoker import invoke

from tests import get_combined_verify_output


def make_output_scrubber(**extra_tokens: str) -> Scrubber:
default_tokens = {
"KqueueSelector": "Using selector: KqueueSelector",
"EpollSelector": "Using selector: EpollSelector",
}
tokens = default_tokens | extra_tokens
return combine_scrubbers(
click.unstyle,
TokenScrubber(tokens=tokens),
lambda t: t.replace("KqueueSelector", "replaced_selector").replace("EpollSelector", "replaced_selector"),
)


def test_bootstrap_env_no_files(tmp_path_factory: TempPathFactory):
cwd = tmp_path_factory.mktemp("cwd")

Expand Down Expand Up @@ -111,4 +126,7 @@ def test_bootstrap_env_dotenv_different_prompt_scenarios(
)

assert result.exit_code == 0
verify(get_combined_verify_output(result.output, ".env", (cwd / ".env").read_text("utf-8")))
verify(
get_combined_verify_output(result.output, ".env", (cwd / ".env").read_text("utf-8")),
scrubber=make_output_scrubber(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copying {current_working_directory}/.env.template to {current_working_directory}
# comment for token 2 - you should enter a valid value
# another comment

DEBUG: Using selector: KqueueSelector
DEBUG: {replaced_selector}


# another comment
Expand Down

0 comments on commit 4500362

Please sign in to comment.