def testRandomString(self): """ util.random_string: test randomness and length """ length = 8 result1 = crypto.random_string(length) result2 = crypto.random_string(length) assert result1 != result2, ('Expected different random strings, but got "%(result1)s" and "%(result2)s"') % locals() result_string = crypto.random_string(length) assert isinstance(result_string, str), ('Expected an string value, but got ' + str(type(result_string))) result = len(crypto.random_string(length)) expected = length assert result == expected, ('Expected length "%(expected)s" but got "%(result)s"') % locals()
def testRandomString(self): """ util.random_string: test randomness and length """ length = 8 result1 = crypto.random_string(length) result2 = crypto.random_string(length) assert result1 != result2, 'Expected different random strings, but got "%(result1)s" and "%(result2)s"' % locals( ) result_string = crypto.random_string(length) assert isinstance(result_string, str), ('Expected an string value, but got ' + str(type(result_string))) result = len(crypto.random_string(length)) expected = length assert result == expected, 'Expected length "%(expected)s" but got "%(result)s"' % locals( )
def createTestPlugin(self): """ Create test plugin, skiping if plugin exists """ if self.pluginExists(): self.shouldDeleteTestPlugin = False pytest.skip("Won't overwrite existing plugin: {0}".format(self.plugin)) self.key = crypto.random_string(32, 'abcdefg') data = ''' # If you find this file in your wiki plugin directory, you can safely # delete it. import sys, os class Parser: key = '{0}' '''.format(self.key) try: file(self.pluginFilePath('.py'), 'w').write(data) except Exception as err: pytest.skip("Can't create test plugin: {0!s}".format(err))
def createTestPlugin(self): """ Create test plugin, skiping if plugin exists """ if self.pluginExists(): self.shouldDeleteTestPlugin = False pytest.skip("Won't overwrite existing plugin: {0}".format( self.plugin)) self.key = crypto.random_string(32, 'abcdefg') data = ''' # If you find this file in your wiki plugin directory, you can safely # delete it. import sys, os class Parser: key = '{0}' '''.format(self.key) try: file(self.pluginFilePath('.py'), 'w').write(data) except Exception as err: pytest.skip("Can't create test plugin: {0!s}".format(err))
def create_random_string_list(length=14, count=10): """ creates a list of random strings """ chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" return [u"{0}".format(random_string(length, chars)) for counter in range(count)]
def create_random_string_list(length=14, count=10): """ creates a list of random strings """ chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' return [u"{0}".format(random_string(length, chars)) for counter in range(count)]