Add test cases that delete a file during incremental checking#3461
Add test cases that delete a file during incremental checking#3461
Conversation
mypy/test/testcheck.py
Outdated
| new_time = os.stat(target).st_mtime + 1 | ||
| os.utime(target, times=(new_time, new_time)) | ||
| for path in testcase.deleted_paths.get(incremental_step, set()): | ||
| os.remove(path) |
There was a problem hiding this comment.
I think you'll need a try/except around this similar to other places (see tear_down() in same file). That should prevent the AppVeyor flakes (in general on Windows remove() sometimes fails due to e.g. virus checkers having the file open).
| target = full[:-2] | ||
| shutil.copy(full, target) | ||
| # Use retries to work around potential flakiness on Windows (AppVeyor). | ||
| retry_on_error(lambda: shutil.copy(full, target)) |
There was a problem hiding this comment.
I was surprised to see that you need to retry the copy too.
There was a problem hiding this comment.
A test case might first delete a file and the reintroduce it here, and I suspect that this could then require a retry. Not 100% sure though, but it seems better to be defensive since test flakes are very annoying.
| for path in testcase.deleted_paths.get(incremental_step, set()): | ||
| os.remove(path) | ||
| # Use retries to work around potential flakiness on Windows (AppVeyor). | ||
| retry_on_error(lambda: os.remove(path)) |
There was a problem hiding this comment.
The test failures seem to be due to the lack of a return type context. Maybe the retry_on_error() function should just take a Callable[[], None]?
There was a problem hiding this comment.
Changed the return type to Any. The type check might be worth filing as a mypy bug, since it looks like mypy should be able to infer the call -- I'll think about it.
|
I guess there's another try/except needed (but this one doesn't look like it should retry?) |
|
This failure could be different. We don't hit that code path on Linux at all during the failing test case, as far as I can see. |
* master: (23 commits) Make return type of open() more precise (python#3477) Add test cases that delete a file during incremental checking (python#3461) Parse each format-string component separately (python#3390) Don't warn about returning Any if it is a proper subtype of the return type (python#3473) Add __setattr__ support (python#3451) Remove bundled lib-typing (python#3337) Move version of extensions to post-release (python#3348) Fix None slice bounds with strict-optional (python#3445) Allow NewType subclassing NewType. (python#3465) Add console scripts (python#3074) Fix 'variance' label. Change label for variance section to just 'variance' (python#3429) Better error message for invalid package names passed to mypy (python#3447) Fix last character cut in html-report if file does not end with newline (python#3466) Print pytest output as it happens (python#3463) Add mypy roadmap (python#3460) Add flag to avoid interpreting arguments with a default of None as Optional (python#3248) Add type checking plugin support for functions (python#3299) Mismatch of inferred type and return type note (python#3428) Sync typeshed (python#3449) ...
No description provided.