Skip to content

Commit

Permalink
Eliminate dependency on parameterized
Browse files Browse the repository at this point in the history
Signed-off-by: Emil Madsen <sovende@gmail.com>
  • Loading branch information
Skeen committed Feb 18, 2020
1 parent d796bd5 commit f62c7ce
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
21 changes: 13 additions & 8 deletions tests/test_asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import sys
from unittest import TestCase
from parameterized import parameterized

from prometheus_client import CollectorRegistry, Counter, generate_latest
from prometheus_client.exposition import CONTENT_TYPE_LATEST
Expand Down Expand Up @@ -81,13 +80,7 @@ def get_all_output(self):
break
return outputs

@parameterized.expand([
["counter", "A counter", 2],
["counter", "Another counter", 3],
["requests", "Number of requests", 5],
["failed_requests", "Number of failed requests", 7],
])
def test_reports_metrics(self, metric_name, help_text, increments):
def validate_metrics(self, metric_name, help_text, increments):
"""
ASGI app serves the metrics from the provided registry.
"""
Expand Down Expand Up @@ -116,3 +109,15 @@ def test_reports_metrics(self, metric_name, help_text, increments):
self.assertIn("# HELP " + metric_name + "_total " + help_text + "\n", output)
self.assertIn("# TYPE " + metric_name + "_total counter\n", output)
self.assertIn(metric_name + "_total " + str(increments) + ".0\n", output)

def test_report_metrics_1(self):
self.validate_metrics("counter", "A counter", 2)

def test_report_metrics_2(self):
self.validate_metrics("counter", "Another counter", 3)

def test_report_metrics_3(self):
self.validate_metrics("requests", "Number of requests", 5)

def test_report_metrics_4(self):
self.validate_metrics("failed_requests", "Number of failed requests", 7)
21 changes: 13 additions & 8 deletions tests/test_wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import sys
from unittest import TestCase
from parameterized import parameterized
from wsgiref.util import setup_testing_defaults
from prometheus_client import make_wsgi_app

Expand Down Expand Up @@ -34,13 +33,7 @@ def assertIn(self, item, iterable):
)
)

@parameterized.expand([
["counter", "A counter", 2],
["counter", "Another counter", 3],
["requests", "Number of requests", 5],
["failed_requests", "Number of failed requests", 7],
])
def test_reports_metrics(self, metric_name, help_text, increments):
def validate_metrics(self, metric_name, help_text, increments):
"""
WSGI app serves the metrics from the provided registry.
"""
Expand All @@ -62,3 +55,15 @@ def test_reports_metrics(self, metric_name, help_text, increments):
self.assertIn("# HELP " + metric_name + "_total " + help_text + "\n", output)
self.assertIn("# TYPE " + metric_name + "_total counter\n", output)
self.assertIn(metric_name + "_total " + str(increments) + ".0\n", output)

def test_report_metrics_1(self):
self.validate_metrics("counter", "A counter", 2)

def test_report_metrics_2(self):
self.validate_metrics("counter", "Another counter", 3)

def test_report_metrics_3(self):
self.validate_metrics("requests", "Number of requests", 5)

def test_report_metrics_4(self):
self.validate_metrics("failed_requests", "Number of failed requests", 7)
2 changes: 0 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ envlist = coverage-clean,py26,py27,py34,py35,py36,py37,py38,pypy,pypy3,{py27,py3
deps =
coverage
pytest
parameterized

[testenv:py26]
; Last pytest and py version supported on py26 .
Expand All @@ -16,7 +15,6 @@ deps =
pytest==2.9.2
coverage
futures
parameterized

[testenv:py27]
deps =
Expand Down

0 comments on commit f62c7ce

Please sign in to comment.