Backport mock assertions for Python 2 tests
#2837
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Some of the
//tensorboard/uploader/...tests are currently disabled inPython 2 because our backport of
mockdoesn’t support the requiredassertions. We can’t easily upgrade the dependency (see #2132), but we
can backport those assertions. The assertions backported are:
assert_not_calledassert_calledassert_called_onceThis patch is the combination of (restrictions of) the following
upstream Git commits:
c7d6c7dcafd4482626194528b24f174dd15f5f5e(2014-04-17)8882c2fccb9f7d3b8ba2b5534c0dd9d52343725f(2014-04-17)7ca5d3afe293d5e4d769c1cb2dfccb0688ba1292(2016-03-11)07532a75003ec8e871e494f9f1ab8f28fa246f08(2018-01-19)I identified those commits by diffing our pinned version of
mock.py(the version at upstream commits
b14e284throughdc1458a) againstthe version of
mock/mock.pyin the current repo, tracing the blame onthe implementation of the relevant assertions, then pruning commits that
relied on other changes not yet patched in (and were only cosmetic,
anyway).
Test Plan:
Unit tests pass in Python 2, and are now actually run, too. Changing
uploader_test.py’stest_upload_swallows_rpc_failureto comment outthe
_upload_oncecall causes the subsequentassert_called_oncetofail with the correct error message, showing that the assertions are
wired up properly.
wchargin-branch: mock-backport