From c7c0e77a813c48513613f0540a03453a7640374d Mon Sep 17 00:00:00 2001 From: pytlab Date: Tue, 12 Dec 2017 21:19:39 +0800 Subject: [PATCH] Add individual descriptors test. --- tests/individual_test.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/individual_test.py b/tests/individual_test.py index 6e4519c..fa49e9c 100644 --- a/tests/individual_test.py +++ b/tests/individual_test.py @@ -36,6 +36,14 @@ def test_binary_encoding(self): # Test decode. self.assertListEqual(indv.decode(), [0.396484375, 0.658203125]) + def test_descriptors(self): + ''' Make sure descriptors can check the parameters correctly. + ''' + self.assertRaises(TypeError, BinaryIndividual, ranges=0.1, eps=0.001, verbosity=0) + self.assertRaises(TypeError, BinaryIndividual, ranges=[(0, 1)], eps='asdf', verbosity=0) + self.assertRaises(ValueError, BinaryIndividual, ranges=[(0, 1)], eps=10.0, verbosity=0) + self.assertRaises(ValueError, BinaryIndividual, ranges=[(0, 1)], eps=[1, 2], verbosity=0) + def test_init(self): ''' Make sure the individual can be initialized correctly. '''