From 241f5e9e894a89f3507b9ad6b31c8b4e5db02ec9 Mon Sep 17 00:00:00 2001 From: EREPPLab <60016577+EREPPLab@users.noreply.github.com> Date: Tue, 27 Oct 2020 15:35:56 -0400 Subject: [PATCH] Chnaged testing and word in setter error --- src/attributes.py | 2 +- src/test_EasyGA.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/attributes.py b/src/attributes.py index 31e6239..101dc10 100644 --- a/src/attributes.py +++ b/src/attributes.py @@ -86,5 +86,5 @@ class attributes: @population_size.setter def population_size(self, value_input): if(value_input == 0): - raise ValueError("Population length must be greater then 0") + raise ValueError("Population size must be greater then 0") self._population_size = value_input diff --git a/src/test_EasyGA.py b/src/test_EasyGA.py index cc33dc3..6c6644a 100644 --- a/src/test_EasyGA.py +++ b/src/test_EasyGA.py @@ -12,13 +12,23 @@ import EasyGA def test_population_size(): """Test the population size is create correctly""" - pass + + for i in range(1,100): + # Create the ga to test + ga = EasyGA.GA() + # Set the upper limit of testing + ga.population_size = i + # Evolve the ga + ga.evolve() + + # If they are not equal throw an error + assert ga.population.size() == ga.population_size def test_chromosome_length(): """ Test to see if the actual chromosome length is the same as defined.""" # Test from 0 to 100 chromosome length - for i in range(0,100): + for i in range(1,100): # Create the ga to test ga = EasyGA.GA() # Set the upper limit of testing