def test_random_string(self): assert_equal(len(util.random_string()), 6) assert_equal(len(util.random_string(8)), 8) assert re.match( '[{0}{1}]{{6}}'.format(string.ascii_uppercase, string.digits), util.random_string()) assert re.match( '[{0}{1}]{{8}}'.format(string.ascii_uppercase, string.digits), util.random_string(8)) assert re.match('[{0}]{{7}}'.format(string.ascii_lowercase), util.random_string(7, string.ascii_lowercase))
def __init__(self, simulation_class, *args, **kwdargs): """ Set up the simulation batch handler Parameters: simulation_class The class representing the :py:class:`~simulations.simulation.Simulation` to run Keyword Parameters: default_handlers Flag to set default event handlers for some events (default True) option_error_handler An error handler for the :py:class:`~simulations.optionparser.OptionParser` option_exit_handler An exit handler for the :py:class:`~simulations.optionparser.OptionParser` """ super(SimulationRunner, self).__init__(*args, **kwdargs) self.data = {} self._task_dup_num = False self._simulation_class = simulation_class self.finished_count = 0 self.identifier = random_string()
def test_random_string(self): assert_equal(len(util.random_string()), 6) assert_equal(len(util.random_string(8)), 8) assert re.match('[{0}{1}]{{6}}'.format(string.ascii_uppercase, string.digits), util.random_string()) assert re.match('[{0}{1}]{{8}}'.format(string.ascii_uppercase, string.digits), util.random_string(8)) assert re.match('[{0}]{{7}}'.format(string.ascii_lowercase), util.random_string(7, string.ascii_lowercase))