Skip to content

Handle flags in pytest passthrough #3467

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

Merged
merged 3 commits into from
May 30, 2017
Merged

Conversation

pkch
Copy link
Contributor

@pkch pkch commented May 26, 2017

Continuing #3463 to handle flags.

We should probably collect a few more reports on flags not handled well before merging.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another flag we might want to pass through is -j (though it becomes -n IIRC).

@@ -111,7 +111,7 @@ def add_pytest(self, name: str, pytest_args: List[str], coverage: bool = False)
else:
args = [sys.executable, '-m', 'pytest'] + pytest_args

self.waiter.add(LazySubprocess(full_name, args, env=self.env, passthrough=True),
self.waiter.add(LazySubprocess(full_name, args, env=self.env, passthrough=self.verbosity),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, I'd append -q to args if verbosity is < 0 and a number of -v flags if it is >= 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can handle -j and -q/-v this way, but we'll need to be careful with the logic (e.g., if there's -v and -p -v, should those -v be added up, or does one supercede the other?).

The other option is not to pass through -j / -q / -v, and just let the user set pytest options directly using the existing -p flag which passes the next argument directly to pytest: python runtests.py -j8 -p -n4 currently means "run pytest with 4 parallel workers, and the other tests with 8".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather not have to use the (rather obscure) -p flag. I think we should compute appropriate verbosity and parallelism flags for pytest from the runtests.py flags -- if you want to run pytest more verbose you can run it manually, and if you want to run it less verbose, well, verbosity is not very subtle.

The other alternative is not to do anything more about this (apart from merging this PR) and instead work on getting rid of runtests.py altogether. I can never figure out how to select a test anyways (mostly because I don't know how the output from a failed test translates into arguments that run just that test).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, for now I updated this PR to handle -q, -v, and -j; I think moving to pytests is slowly happening, but will take time.

@gvanrossum gvanrossum self-assigned this May 29, 2017
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there. (Did you check that the semantics of -q and -v are compatible?)

mypy/waiter.py Outdated
@@ -37,13 +37,11 @@ def __init__(self, name: str, args: List[str], *, cwd: str = None,
self.passthrough = passthrough

def start(self) -> None:
if self.passthrough is None:
if self.passthrough is None or self.passthrough < 0:
self.outfile = tempfile.TemporaryFile()
else:
if self.passthrough >= 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this if -- it makes it look as if there's a case where self.outfile won't be set at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right. Also, currently with python runtests.py -q I completely suppress pytest output (since that was the original behavior of python runtests.py -q). Should I perhaps still let it pass through its output? With -q, pytest output is just a bunch of dots, so it actually fits well with runtests.py output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, pytest -q misbehaves in the presence of xdist, so I'm keeping the behavior as is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even without xdist I can't get pytest to not print the row of dots. So agreed, let's keep the existing behavior of runtests.py not passing through any output on -q.

@pkch
Copy link
Contributor Author

pkch commented May 30, 2017

-q and -v are compatible in the sense that they decrease/increase verbosity in pytest; and lower/higher verbosity does behave similarly for pytest and runtests.py.

@gvanrossum gvanrossum merged commit 154486b into python:master May 30, 2017
@gvanrossum
Copy link
Member

OK, let's see how people like this.

carljm added a commit to carljm/mypy that referenced this pull request May 31, 2017
* master:
  Support accessing modules imported in class bodies within methods. (python#3450)
  Make Type[X] compatible with metaclass of X (python#3346)
  Sync typeshed (python#3479)
  Handle flags in pytest passthrough (python#3467)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants