Skip to content

Commit

Permalink
Merge pull request python-diamond#98 from SemanticsOS/lambdafu/metric…
Browse files Browse the repository at this point in the history
…parsefix

Fix unbalanced parenthesis in Metric.parse.
  • Loading branch information
mattrobenolt committed Feb 15, 2015
2 parents 23a0af7 + aac7976 commit a83470d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/diamond/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def parse(cls, string):
Parse a string and create a metric
"""
match = re.match(r'^(?P<name>[A-Za-z0-9\.\-_]+)\s+'
+ '\(?P<value>[0-9\.]+)\s+'
+ '(?P<value>[0-9\.]+)\s+'
+ '(?P<timestamp>[0-9\.]+)(\n?)$',
string)
try:
Expand Down
9 changes: 9 additions & 0 deletions src/diamond/test/testmetric.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ def testgetMetricPathHostNone(self):
message = 'Actual %s, expected %s' % (actual_value, expected_value)
self.assertEqual(actual_value, expected_value, message)

def test_parse(self):
metric = Metric('test.parse', 0)

actual_value = str(metric).strip()
expected_value = str(Metric.parse(actual_value)).strip()

message = 'Actual %s, expected %s' % (actual_value, expected_value)
self.assertEqual(actual_value, expected_value, message)

def test_issue_723(self):
metrics = [
9.97143369909e-05,
Expand Down

0 comments on commit a83470d

Please sign in to comment.