python-parameterized/remove_nose.patch

126 lines
4.6 KiB
Diff
Raw Normal View History

---
parameterized/parameterized.py | 2 +-
parameterized/test.py | 34 ++++++++++++++--------------------
2 files changed, 15 insertions(+), 21 deletions(-)
--- a/parameterized/parameterized.py
+++ b/parameterized/parameterized.py
@@ -342,7 +342,7 @@ def default_name_func(func, num, p):
_test_runner_override = None
_test_runner_guess = False
-_test_runners = set(["unittest", "unittest2", "nose", "nose2", "pytest"])
+_test_runners = set(["unittest", "unittest2", "nose2", "pytest"])
_test_runner_aliases = {
"_pytest": "pytest",
}
--- a/parameterized/test.py
+++ b/parameterized/test.py
@@ -5,13 +5,7 @@ import sys
import mock
from functools import wraps
from unittest import TestCase
-try:
- from nose.tools import assert_equal, assert_raises
-except ImportError:
- def assert_equal(*args, **kwds):
- return TestCase().assertEqual(*args, **kwds)
- def assert_raises(*args, **kwds):
- return TestCase().assertRaises(*args, **kwds)
+import pytest
from .parameterized import (
PY3, PY2, parameterized, param, parameterized_argument_value_pairs,
@@ -145,12 +139,12 @@ if not PYTEST:
self.actual_order = self.stack.pop(0)
def tearDown(self):
- missing_tests.remove("teardown_called(%s)" %(self.stack.pop(0), ))
+ missing_tests.remove("teardown_called(%s)" % (self.stack.pop(0), ))
@parameterized([(1, ), (2, )])
def test_setup(self, count, *a):
- assert_equal(self.actual_order, "setup %s" %(count, ))
- missing_tests.remove("test_setup(%s)" %(self.actual_order, ))
+ assert self.actual_order == "setup %s" % count
+ missing_tests.remove("test_setup(%s)" % self.actual_order)
def custom_naming_func(custom_tag):
@@ -361,9 +355,9 @@ class TestParamerizedOnTestCase(TestCase
frame_locals = frame[0].f_locals
nose_test_method_name = frame_locals['a'][0]._testMethodName
expected_name = "test_on_TestCase2_custom_name_" + parameterized.to_safe_name(foo)
- assert_equal(nose_test_method_name, expected_name,
- "Test Method name '%s' did not get customized to expected: '%s'" %
- (nose_test_method_name, expected_name))
+ assert nose_test_method_name == expected_name, \
+ "Test Method name '%s' did not get customized to expected: '%s'" % \
+ (nose_test_method_name, expected_name)
missing_tests.remove("%s(%r, bar=%r)" %(expected_name, foo, bar))
@@ -385,7 +379,7 @@ class TestParameterizedExpandDocstring(T
actual_docstring = test_method.__doc__
if rstrip:
actual_docstring = actual_docstring.rstrip()
- assert_equal(actual_docstring, expected_docstring)
+ assert actual_docstring == expected_docstring
@parameterized.expand([param("foo")],
doc_func=lambda f, n, p: "stuff")
@@ -453,7 +447,7 @@ def test_helpful_error_on_empty_iterable
def test_skip_test_on_empty_iterable():
func = parameterized([], skip_on_empty=True)(lambda: None)
- assert_raises(SkipTest, func)
+ pytest.raises(SkipTest, func)
def test_helpful_error_on_empty_iterable_input_expand():
@@ -486,7 +480,7 @@ def test_helpful_error_on_non_iterable_i
def tearDownModule():
missing = sorted(list(missing_tests))
- assert_equal(missing, [])
+ assert missing == []
def test_old_style_classes():
if PY3:
@@ -536,7 +530,7 @@ class TestOldStyleClass:
def test_parameterized_argument_value_pairs(func_params, p, expected):
helper = eval("lambda %s: None" %(func_params, ))
actual = parameterized_argument_value_pairs(helper, p)
- assert_equal(actual, expected)
+ assert actual == expected
@parameterized([
@@ -546,7 +540,7 @@ def test_parameterized_argument_value_pa
(123456789, "12...89", 4),
])
def test_short_repr(input, expected, n=6):
- assert_equal(short_repr(input, n=n), expected)
+ assert short_repr(input, n=n) == expected
@parameterized([
("foo", ),
@@ -560,7 +554,7 @@ cases_over_10 = [(i, i+1) for i in range
@parameterized(cases_over_10)
def test_cases_over_10(input, expected):
- assert_equal(input, expected-1)
+ assert input == expected-1
@parameterized_class(("a", "b", "c"), [
@@ -579,7 +573,7 @@ class TestParameterizedClass(TestCase):
def _assertions(self, test_name):
assert hasattr(self, "a")
- assert_equal(self.b + self.c, 3)
+ assert self.b + self.c == 3
missing_tests.remove("%s:%s(%r, %r, %r)" %(
self.__class__.__name__,
test_name,