Skip to content

Convert tasks example to use logging for testability #1219

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 2 commits into from
Nov 15, 2017

Conversation

andrewsg
Copy link
Member

No description provided.

@andrewsg andrewsg requested a review from theacodes November 14, 2017 23:08
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 14, 2017
@theacodes
Copy link
Contributor

We generally don't use logging in our samples, what about this makes the sample more testable?

@andrewsg
Copy link
Member Author

Previously we had print() which turned out to be hard to reliably mock in a way that works across Py2 and 3. Logging is easy to mock. Either way, the output goes to the same place; we need some sort of off-instance data storage to prove the task ran, and the logging console is the most convenient place without pulling in another dependency.

@andrewsg andrewsg merged commit 19788b0 into GoogleCloudPlatform:master Nov 15, 2017
arithmetic1728 pushed a commit to googleapis/python-tasks that referenced this pull request Sep 2, 2020
…CloudPlatform/python-docs-samples#1219)

* Convert tasks example to use logging for testability

* Use capsys to test tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants