diff --git a/chatterbot/utils.py b/chatterbot/utils.py index c39a0d52a..684d7f7bf 100644 --- a/chatterbot/utils.py +++ b/chatterbot/utils.py @@ -171,31 +171,6 @@ def get_response_time(chatbot): return time.time() - start_time -def generate_strings(total_strings, string_length=20): - """ - Generate a list of random strings. - - :param total_strings: The number of strings to generate. - :type total_strings: int - - :param string_length: The length of each string to generate. - :type string_length: int - - :returns: The generated list of random strings. - :rtype: list - """ - import random - import string - - statements = [] - for _ in range(0, total_strings): - text = ''.join( - random.choice(string.ascii_letters + string.digits + ' ') for _ in range(string_length) - ) - statements.append(text) - return statements - - def print_progress_bar(description, iteration_counter, total_items, progress_bar_length=20): """ Print progress bar diff --git a/docs/utils.rst b/docs/utils.rst index e436a2eea..d29abb966 100644 --- a/docs/utils.rst +++ b/docs/utils.rst @@ -41,12 +41,6 @@ ChatBot response time .. autofunction:: chatterbot.utils.get_response_time -Random string generation ------------------------- - -.. autofunction:: chatterbot.utils.generate_strings - - Parsing datetime information ---------------------------- diff --git a/tests/test_benchmarks.py b/tests/test_benchmarks.py index 5d05d18e2..06d4045cf 100644 --- a/tests/test_benchmarks.py +++ b/tests/test_benchmarks.py @@ -7,6 +7,7 @@ from .base_case import ChatBotSQLTestCase, ChatBotMongoTestCase from chatterbot import ChatBot from chatterbot import utils +from factory import Faker import sys import logging @@ -16,7 +17,8 @@ level=logging.INFO ) -STATEMENT_LIST = utils.generate_strings(10) +# Generate a list of random sentences +STATEMENT_LIST = Faker('sentences', nb=10).generate({}) class BenchmarkingMixin(object): @@ -96,14 +98,13 @@ def test_synset_distance_comparisons(self): ] }) - self.assert_response_duration(1.9, kwargs) + self.assert_response_duration(3.5, kwargs) def test_english_corpus_training(self): """ Test the amount of time it takes to train with the English corpus. """ - import unittest - raise unittest.SkipTest('TODO: This test needs to be written.') + self.skipTest('TODO: This test needs to be written.') class MongoBenchmarkingTests(BenchmarkingMixin, ChatBotMongoTestCase): @@ -154,5 +155,4 @@ def test_english_corpus_training(self): """ Test the amount of time it takes to train with the English corpus. """ - import unittest - raise unittest.SkipTest('TODO: This test needs to be written.') + self.skipTest('TODO: This test needs to be written.') diff --git a/tests/test_utils.py b/tests/test_utils.py index 602b73eda..de97a3b0a 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -28,15 +28,6 @@ def test_remove_stop_words(self): self.assertIn('test', list(words)) self.assertIn('string', list(words)) - def test_generate_strings(self): - """ - Test that we can generate 2 strings of length 10. - """ - strings = utils.generate_strings(2, 10) - self.assertEqual(len(strings), 2) - self.assertEqual(len(strings[0]), 10) - self.assertEqual(len(strings[1]), 10) - class UtilityChatBotTestCase(ChatBotTestCase):