def test_it_should_only_return_an_array_of_strings_containing_only_1_and_0():
    asserted_pool = seeding.pool(8, range(255), 64)
    for asserted_string in asserted_pool:
        for i in asserted_string:
            assert (i == "1" or i == "0")
from genetic_algorithms_py import seeding
from genetic_algorithms_py import reproduction
from genetic_algorithms_py import crossover


black_box = lambda x, y: y + x ** 2
params = {
    "objective_function": black_box,
    "pool": seeding.pool(8, range(255), 2),
    "constraint_range": range(-6, 6),
    "pool_size": 8,
    "number_of_variables": 2,
    "carry_over": 2,
    "max": True,
    "function_name": "NoseTests",
    "crossover_rate": 0.7,
}


def test_it_should_return_an_array_of_size_2():
    params["pool"] = reproduction.reproduce(params)
    asserted_pool = crossover.crossover(params)
    assert len(asserted_pool) >= 2


def test_it_should_return_an_array_of_strings():
    params["pool"] = reproduction.reproduce(params)
    asserted_pool = crossover.crossover(params)
    for asserted in asserted_pool:
        assert isinstance(asserted, str)
def test_it_should_return_an_array_of_string():
    asserted_pool = seeding.pool(8, range(255), 1)
    assert len(asserted_pool) == 8
import itertools
from genetic_algorithms_py import seeding
from genetic_algorithms_py import reproduction

black_box = (lambda x, y: y + x ** 2)

params = {'objective_function': black_box,
          'pool': seeding.pool(8, range(255), 2),
          'pool_size': 64,
          "constraint_range": range(-6, 6),
          'number_of_variables': 2,
          'max': True,
          'function_name': 'NoseTests',
          'carry_over': 2}


def test_it_should_return_an_array_of_strings():
    asserted_pool = reproduction.reproduce(params)
    for asserted in asserted_pool:
        assert isinstance(asserted, str)


def test_it_should_return_an_array_of_strings_of_length_8():
    params['carry_over'] = 32
    for i in range(10):
        asserted_pool = reproduction.reproduce(params)
        assert len(asserted_pool) == 32


# Testing private methods NB: Wouldn't normally keep these
def test__build_dictionary_should_return_a_collection_of_size_8():