Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion email_validator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def main(dns_resolver: Optional[_Resolver] = None) -> None:
# Set options from environment variables.
options: dict[str, Any] = {}
for varname in ('ALLOW_SMTPUTF8', 'ALLOW_EMPTY_LOCAL', 'ALLOW_QUOTED_LOCAL', 'ALLOW_DOMAIN_LITERAL',
'ALLOW_DISPLAY_NAME',
'ALLOW_DISPLAY_NAME', 'STRICT',
'GLOBALLY_DELIVERABLE', 'CHECK_DELIVERABILITY', 'TEST_ENVIRONMENT'):
if varname in os.environ:
# bool() would make any non-empty string True, so e.g.
Expand Down
10 changes: 10 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ def test_main_falsy_test_environment_from_env(monkeypatch: pytest.MonkeyPatch, c
assert stdout == 'The part after the @-sign is a special-use or reserved name that cannot be used with email.\n'


@pytest.mark.parametrize('value', ['true', '1'])
def test_main_strict_from_env(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], value: str) -> None:
monkeypatch.setenv('STRICT', value)
monkeypatch.setenv('CHECK_DELIVERABILITY', 'false')
monkeypatch.setattr('sys.argv', ['email_validator', 'a' * 65 + '@example.com'])
validator_command_line_tool(dns_resolver=RESOLVER)
stdout, _ = capsys.readouterr()
assert stdout == 'The email address is too long before the @-sign (1 character too many).\n'


def test_main_default_timeout_from_env(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]) -> None:
import json
import email_validator
Expand Down