diff --git a/chatterbot/trainers.py b/chatterbot/trainers.py index 0a4b59a1f..e7f22ccf2 100644 --- a/chatterbot/trainers.py +++ b/chatterbot/trainers.py @@ -13,6 +13,7 @@ class Trainer(object): def __init__(self, storage, **kwargs): self.storage = storage self.logger = logging.getLogger(__name__) + self.show_training_progress = kwargs.get('show_training_progress', True) def train(self, *args, **kwargs): """ @@ -81,7 +82,11 @@ def train(self, conversation): previous_statement_text = None for conversation_count, text in enumerate(conversation): - print_progress_bar("List Trainer", conversation_count + 1, len(conversation)) + if self.show_training_progress: + print_progress_bar( + 'List Trainer', + conversation_count + 1, len(conversation) + ) statement = self.get_or_create(text) @@ -121,11 +126,13 @@ def train(self, *corpus_paths): corpus_files = self.corpus.list_corpus_files(corpus_path) for corpus_count, corpus in enumerate(corpora): for conversation_count, conversation in enumerate(corpus): - print_progress_bar( - str(os.path.basename(corpus_files[corpus_count])) + " Training", - conversation_count + 1, - len(corpus) - ) + + if self.show_training_progress: + print_progress_bar( + str(os.path.basename(corpus_files[corpus_count])) + ' Training', + conversation_count + 1, + len(corpus) + ) previous_statement_text = None diff --git a/runtests.py b/runtests.py index 1a8329cb5..e68150282 100644 --- a/runtests.py +++ b/runtests.py @@ -15,6 +15,8 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'tests_django.test_settings' django.setup() TestRunner = get_runner(settings) - test_runner = TestRunner() + test_runner = TestRunner( + verbosity=2 + ) failures = test_runner.run_tests(['tests_django']) sys.exit(bool(failures)) diff --git a/setup.cfg b/setup.cfg index 4877d61bb..5b1f0f5ad 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,6 +8,7 @@ universal = 1 description-file = README.md [nosetests] +verbosity = 3 exclude = (?:^tests_django$) with-coverage = true cover-package = chatterbot @@ -16,8 +17,4 @@ cover-package = chatterbot # H306: imports not in alphabetical order (time, os) ignore = H306 max_line_length = 175 -exclude = - .eggs, - .git, - .tox, - build, \ No newline at end of file +exclude = .eggs, .git, .tox, build, \ No newline at end of file diff --git a/tests/base_case.py b/tests/base_case.py index f4dc662e1..41b7bcf7c 100644 --- a/tests/base_case.py +++ b/tests/base_case.py @@ -27,6 +27,7 @@ def get_kwargs(self): return { 'input_adapter': 'chatterbot.input.VariableInputTypeAdapter', 'output_adapter': 'chatterbot.output.OutputAdapter', + 'show_training_progress': False, # Run the test database in-memory 'database': None } diff --git a/tests/filter_integration_tests/test_filters_with_mongo_storage.py b/tests/filter_integration_tests/test_filters_with_mongo_storage.py index ada988c2f..0a1375439 100644 --- a/tests/filter_integration_tests/test_filters_with_mongo_storage.py +++ b/tests/filter_integration_tests/test_filters_with_mongo_storage.py @@ -14,7 +14,7 @@ def test_filter_selection(self): from chatterbot.trainers import ListTrainer self.chatbot.filters = (RepetitiveResponseFilter(), ) - self.chatbot.set_trainer(ListTrainer) + self.chatbot.set_trainer(ListTrainer, **self.get_kwargs()) self.chatbot.train([ 'Hello', diff --git a/tests/logic_adapter_tests/best_match_integration_tests/test_sentiment_comparison.py b/tests/logic_adapter_tests/best_match_integration_tests/test_sentiment_comparison.py index 2b0f69bf4..245760359 100644 --- a/tests/logic_adapter_tests/best_match_integration_tests/test_sentiment_comparison.py +++ b/tests/logic_adapter_tests/best_match_integration_tests/test_sentiment_comparison.py @@ -14,7 +14,7 @@ def setUp(self): from chatterbot.trainers import ListTrainer from chatterbot.comparisons import sentiment_comparison - self.chatbot.set_trainer(ListTrainer) + self.chatbot.set_trainer(ListTrainer, **self.get_kwargs()) self.adapter = BestMatch( statement_comparison_function=sentiment_comparison ) diff --git a/tests/logic_adapter_tests/test_data_cache.py b/tests/logic_adapter_tests/test_data_cache.py index 88bbe9a12..0c897212c 100644 --- a/tests/logic_adapter_tests/test_data_cache.py +++ b/tests/logic_adapter_tests/test_data_cache.py @@ -25,7 +25,7 @@ def setUp(self): self.chatbot.logic = DummyMutatorLogicAdapter() self.chatbot.logic.set_chatbot(self.chatbot) - self.chatbot.set_trainer(ListTrainer) + self.chatbot.set_trainer(ListTrainer, **self.get_kwargs()) self.chatbot.train([ 'Hello', diff --git a/tests_django/integration_tests/test_chatterbot_corpus_training.py b/tests_django/integration_tests/test_chatterbot_corpus_training.py index fa6725740..b275df3b6 100644 --- a/tests_django/integration_tests/test_chatterbot_corpus_training.py +++ b/tests_django/integration_tests/test_chatterbot_corpus_training.py @@ -14,7 +14,10 @@ class ChatterBotCorpusTrainingTestCase(TestCase): def setUp(self): super(ChatterBotCorpusTrainingTestCase, self).setUp() self.chatbot = ChatBot(**settings.CHATTERBOT) - self.chatbot.set_trainer(ChatterBotCorpusTrainer) + self.chatbot.set_trainer( + ChatterBotCorpusTrainer, + **settings.CHATTERBOT + ) def tearDown(self): super(ChatterBotCorpusTrainingTestCase, self).setUp() diff --git a/tests_django/test_settings.py b/tests_django/test_settings.py index ce53da4df..5b95cfb0e 100644 --- a/tests_django/test_settings.py +++ b/tests_django/test_settings.py @@ -23,6 +23,7 @@ 'training_data': [ 'chatterbot.corpus.english.greetings' ], + 'show_training_progress': False, 'logic_adapters': [ { 'import_path': 'chatterbot.logic.BestMatch',