added tests
This commit is contained in:
@ -4,15 +4,39 @@ import EasyGA
|
|||||||
# USE THIS COMMAND WHEN TESTING -
|
# USE THIS COMMAND WHEN TESTING -
|
||||||
# python3 -m pytest
|
# python3 -m pytest
|
||||||
|
|
||||||
|
# Tests can be broken down into three parts.
|
||||||
|
# - Testing correct size
|
||||||
|
# - Testing size while integrated with our function
|
||||||
|
# - Testing correct value
|
||||||
|
# - Testing integration with other functions
|
||||||
|
|
||||||
|
def test_population_size():
|
||||||
|
"""Test the population size is create correctly"""
|
||||||
|
pass
|
||||||
|
|
||||||
def test_chromosome_length():
|
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(0,100):
|
||||||
|
# Create the ga to test
|
||||||
ga = EasyGA.GA()
|
ga = EasyGA.GA()
|
||||||
ga.chromosome_length = 100
|
# Set the upper limit of testing
|
||||||
|
ga.chromosome_length = i
|
||||||
|
# Evolve the ga
|
||||||
ga.evolve()
|
ga.evolve()
|
||||||
|
|
||||||
""" Test to see if the actual chromosome length is the same as defined."""
|
# If they are not equal throw an error
|
||||||
assert ga.population.chromosome_list[0].size() == ga.chromosome_length
|
assert ga.population.chromosome_list[0].size() == ga.chromosome_length
|
||||||
|
|
||||||
|
def test_gene_value():
|
||||||
|
""" """
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_initilization():
|
||||||
|
""" """
|
||||||
|
pass
|
||||||
|
|
||||||
def test_second():
|
def test_second():
|
||||||
|
|
||||||
assert 1 + 1 == 2
|
assert 1 + 1 == 2
|
||||||
|
|||||||
Reference in New Issue
Block a user