From 3c53b4944b76a49d0bc5f0b36e64b6295bc56502 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Sat, 19 Mar 2016 16:54:56 -0400 Subject: [PATCH] TEST: Test not calling super()._validate. --- tests/pipeline/test_term.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/pipeline/test_term.py b/tests/pipeline/test_term.py index d8820e55..0c6ed5c7 100644 --- a/tests/pipeline/test_term.py +++ b/tests/pipeline/test_term.py @@ -343,6 +343,27 @@ class ObjectIdentityTestCase(TestCase): with self.assertRaises(UnsupportedDType): SomeFactor(dtype=complex128_dtype) + def test_require_super_call_in_validate(self): + + class MyFactor(Factor): + inputs = () + dtype = float64_dtype + window_length = 0 + + def _validate(self): + "Woops, I didn't call super()!" + + with self.assertRaises(AssertionError) as e: + MyFactor() + + errmsg = str(e.exception) + self.assertEqual( + errmsg, + "Term._validate() was not called.\n" + "This probably means that you overrode _validate" + " without calling super()." + ) + def test_latest_on_different_dtypes(self): factor_dtypes = (float64_dtype, datetime64ns_dtype) for column in TestingDataSet.columns: