-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config options handle spaces and newlines #93
Conversation
… and --trio200-blocking-calls now handle spaces and newlines
for arg in reg_match.group().split(" "): | ||
if arg.strip(): | ||
parsed_args.append(arg.strip()) | ||
parsed_args.append(reg_match.group().strip()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good - I'll next have internet around Jan 9th, so don't panic if review is a bit delayed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gtk, I'll rebase and fix merge conflicts in it. May also split it up if I start messing with stuff in other PR's that might lead to conflicts.
def test_200_from_config_flake8_internals( | ||
tmp_path: Path, capsys: pytest.CaptureFixture[str] | ||
): | ||
# abuse flake8 internals to avoid having to use subprocess | ||
# which breaks breakpoints and hinders debugging | ||
# TODO: fixture (?) to change working directory | ||
|
||
err_msg = _test_trio200_from_config_common(tmp_path) | ||
# replace ./ with tmp_path/ | ||
err_msg = str(tmp_path) + err_msg[1:] | ||
|
||
from flake8.main.cli import main | ||
|
||
main( | ||
argv=[ | ||
str(tmp_path / "example.py"), | ||
"--append-config", | ||
str(tmp_path / ".flake8"), | ||
] | ||
) | ||
out, err = capsys.readouterr() | ||
assert not err | ||
assert err_msg == out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost funny after the fact how massively the subprocess
call broke my debugging workflow and made finding out why tests broke take ages (a trailing comma in the list of config options).
I broke this out as a separate test in case flake8 internals break, but feels like there should be a cleaner solution that doesn't rely on any internal structure at all and just emulates calling it with python -m
. Something like runpy.run_module
but with also setting sys.argv
and working dir. I didn't find anything that didn't require writing a bunch of extra code, but if you have anything I'd love to hear of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No specific advice sorry, but I appreciate having this test broken out!
def test_200_from_config_flake8_internals( | ||
tmp_path: Path, capsys: pytest.CaptureFixture[str] | ||
): | ||
# abuse flake8 internals to avoid having to use subprocess | ||
# which breaks breakpoints and hinders debugging | ||
# TODO: fixture (?) to change working directory | ||
|
||
err_msg = _test_trio200_from_config_common(tmp_path) | ||
# replace ./ with tmp_path/ | ||
err_msg = str(tmp_path) + err_msg[1:] | ||
|
||
from flake8.main.cli import main | ||
|
||
main( | ||
argv=[ | ||
str(tmp_path / "example.py"), | ||
"--append-config", | ||
str(tmp_path / ".flake8"), | ||
] | ||
) | ||
out, err = capsys.readouterr() | ||
assert not err | ||
assert err_msg == out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No specific advice sorry, but I appreciate having this test broken out!
for arg in reg_match.group().split(" "): | ||
if arg.strip(): | ||
parsed_args.append(arg.strip()) | ||
parsed_args.append(reg_match.group().strip()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good - I'll next have internet around Jan 9th, so don't panic if review is a bit delayed.
fix #84 and #89
--startable-in-context-manager
and--trio200-blocking-calls
now handle spaces and newlines.