Skip to content
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

_TimedContextManagerDecorator enter -> self #147

Merged
merged 3 commits into from
Aug 24, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions datadog/dogstatsd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def __enter__(self):
if not self.metric:
raise TypeError("Cannot used timed without a metric!")
self.start = time()
return self

def __exit__(self, type, value, traceback):
# Report the elapsed time of the context manager.
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/dogstatsd/test_statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ def test_timed_context(self):
Measure the distribution of a context's run time.
"""
# In seconds
with self.statsd.timed('timed_context.test'):
with self.statsd.timed('timed_context.test') as timer:
self.assertIsInstance(timer,
Copy link
Member

Choose a reason for hiding this comment

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

I need to update the tests to inherit from unittest. In the meantime would you mind using

t.assert_is_instance(...)

rather than

self.assertIsIstance(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

Choose a reason for hiding this comment

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

Almost 😄 it should be t.assert... rather than self.assert...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. I've haven't run across nose.tools being used before. Should be in place now.

DogStatsd._TimedContextManagerDecorator)
time.sleep(0.5)

packet = self.recv()
Expand Down