def randomize_value(self) -> None: if (config.INSTANCE.constant_seeding and StaticConstantSeeding().has_strings and randomness.next_float() <= 0.90): self._value = StaticConstantSeeding().random_string else: length = randomness.next_int(0, config.INSTANCE.string_length + 1) self._value = randomness.next_string(length)
def randomize_value(self) -> None: use_seed = ( randomness.next_float() <= config.configuration.seeded_primitives_reuse_probability ) if ( config.configuration.dynamic_constant_seeding and dynamic_constant_seeding.has_strings and use_seed and config.configuration.constant_seeding and randomness.next_float() <= config.configuration.seeded_dynamic_values_reuse_probability ): self._value = dynamic_constant_seeding.random_string elif ( config.configuration.constant_seeding and static_constant_seeding.has_strings and use_seed ): self._value = static_constant_seeding.random_string else: length = randomness.next_int(0, config.configuration.string_length + 1) self._value = randomness.next_string(length)
def test_next_string_zero(): rand = randomness.next_string(0) assert rand == ""
def test_next_string_printable(): rand = randomness.next_string(15) assert all(char in string.printable for char in rand)
def test_next_string_length(): assert len(randomness.next_string(15)) == 15