From 95718c27a80df2c5af438548eda3b50ce632af68 Mon Sep 17 00:00:00 2001 From: enkore Date: Fri, 17 Oct 2014 16:12:59 +0200 Subject: [PATCH] Remember when we switched to py.test? Yeah well, we lost half the tests on the way there. --- tests/test_battery.py | 19 ++++++++----------- tests/test_core_util.py | 12 ++++++------ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/tests/test_battery.py b/tests/test_battery.py index a519e92..72a41ff 100644 --- a/tests/test_battery.py +++ b/tests/test_battery.py @@ -5,16 +5,13 @@ import unittest from i3pystatus import battery -def factory(path, format, expected): - def test(): - bc = battery.BatteryChecker(path=path, format=format) - bc.run() - assert bc.output["full_text"] == expected - test.description = path + ":" + format - return test +def battery_test(path, format, expected): + bc = battery.BatteryChecker(path=path, format=format) + bc.run() + assert bc.output["full_text"] == expected -def basic_test_generator(): +def test_basic(): cases = [ ("test_battery_basic1", "FULL", "0.000", "0h:00m"), ("test_battery_basic2", "FULL", "0.000", "0h:00m"), @@ -26,6 +23,6 @@ def basic_test_generator(): ("test_battery_broken1", "FULL", "0.000", "0h:00m"), ] for path, status, consumption, remaining in cases: - yield factory(path, "{status}", status) - yield factory(path, "{consumption:.3f}", consumption) - yield factory(path, "{remaining:%hh:%Mm}", remaining) + battery_test(path, "{status}", status) + battery_test(path, "{consumption:.3f}", consumption) + battery_test(path, "{remaining:%hh:%Mm}", remaining) diff --git a/tests/test_core_util.py b/tests/test_core_util.py index 2b9ec7e..020326e 100644 --- a/tests/test_core_util.py +++ b/tests/test_core_util.py @@ -29,7 +29,7 @@ def partition(iterable, limit, assrt): assert sorted(item) in partitions -def partition_test_generator(): +def test_partition(): cases = [ ([1, 2, 3, 4], 3, [[1, 2], [3], [4]]), ([2, 1, 3, 4], 3, [[1, 2], [3], [4]]), @@ -38,14 +38,14 @@ def partition_test_generator(): ] for iterable, limit, assrt in cases: - yield partition, iterable, limit, assrt + partition(iterable, limit, assrt) def popwhile(iterable, predicate, assrt): assert list(util.popwhile(predicate, iterable)) == assrt -def popwhile_test_generator(): +def test_popwhile(): cases = [ ([1, 2, 3, 4], lambda x: x < 2, []), ([1, 2, 3, 4], lambda x: x < 5 and x > 2, [4, 3]), @@ -55,7 +55,7 @@ def popwhile_test_generator(): ] for iterable, predicate, assrt in cases: - yield popwhile, iterable, predicate, assrt + popwhile(iterable, predicate, assrt) def keyconstraintdict_missing(valid, required, feedkeys, assrt_missing): @@ -65,7 +65,7 @@ def keyconstraintdict_missing(valid, required, feedkeys, assrt_missing): assert kcd.missing() == set(assrt_missing) -def keyconstraintdict_missing_test_generator(): +def test_keyconstraintdict_missing(): cases = [ # ( valid, required, feed, missing ) (("foo", "bar", "baz"), ("foo",), ("bar",), ("foo",)), @@ -76,7 +76,7 @@ def keyconstraintdict_missing_test_generator(): ] for valid, required, feed, missing in cases: - yield keyconstraintdict_missing, valid, required, feed, missing + keyconstraintdict_missing(valid, required, feed, missing) class ModuleListTests(unittest.TestCase):