diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 14535df..6c662b6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,11 @@ Unreleased ========== - Don't install python-daemon 2.2.0, it breaks things (#89) +- Remove untested spelling function (#86) + + - The spelling function did very little other than assume it could load + PyEnchant and then ``return True`` if it couldn't. If you really miss this + function, submit a PR with something that actually works and has tests! 3.0.2 ===== diff --git a/README.rst b/README.rst index 6c4497c..5b32790 100644 --- a/README.rst +++ b/README.rst @@ -36,8 +36,7 @@ any other Mail server. - Salmon can also run in a completely separate virtualenv for easy deployment. - A flexible and easy to use routing system lets you write stateful or state\ *less* handlers of your email. -- Helpful tools for unit testing your email applications with nose, including - spell checking with PyEnchant. +- Helpful tools for unit testing your email applications with nose. - Ability to use Jinja2 or Mako templates to craft emails including the headers. - Easily configurable to use alternative sending and receiving systems, diff --git a/salmon/testing.py b/salmon/testing.py index b1264fd..74bd37e 100644 --- a/salmon/testing.py +++ b/salmon/testing.py @@ -1,11 +1,11 @@ """ -A bag of generally useful things when writing unit tests for your Salmon server. -The most important things are the spelling function and using the -TestConversation vs. RouterConversation to talk to your server. +A bag of generally useful things when writing unit tests for your Salmon +server. The most important thing using the TestConversation vs. +RouterConversation to talk to your server. The TestConversation will use the salmon.server.Relay you have configured to -talk to your actual running Salmon server. Since by default Salmon reloads each -file you change it will work to run your tests. +talk to your actual running Salmon server. Since by default Salmon reloads +each file you change it will work to run your tests. However, this isn't that fast, doesn't give you coverage analysis, and doesn't let you test the results. For that you use RouterConversation to do the exact @@ -13,11 +13,8 @@ server through the relay, it just runs all the messages through the router directly. -This is faster and will give you code coverage as well as make sure that all the -modules (not just your handlers) will get reloaded. - -The spelling function will use PyEnchant to spell check a string. If it finds -any errors it prints them out, and returns False. +This is faster and will give you code coverage as well as make sure that all +the modules (not just your handlers) will get reloaded. """ from __future__ import print_function, unicode_literals @@ -29,38 +26,6 @@ TEST_QUEUE = "run/queue" -def spelling(file_name, contents, language="en_US"): - """ - You give it a file_name and the contents of that file and it tells you - if it's spelled correctly. The reason you give it contents is that you - will typically run a template through the render process, so spelling - can't just load a file and check it. - - It assumes you have PyEnchant installed correctly and configured - in your test settings module. Use "salmon spell" to make sure it - works right. - """ - try: - from enchant.checker import SpellChecker - from enchant.tokenize import EmailFilter, URLFilter - except ImportError: - print("Failed to load PyEnchant. Make sure it's installed and salmon spell works.") - return True - - failures = 0 - chkr = SpellChecker(language, filters=[EmailFilter, URLFilter]) - chkr.set_text(contents) - for err in chkr: - print("%s: %s \t %r" % (file_name, err.word, contents[err.wordpos - 20:err.wordpos + 20])) - failures += 1 - - if failures: - print("You have %d spelling errors in %s. Run salmon spell.." % (failures, file_name)) - return False - else: - return True - - def relay(hostname="127.0.0.1", port=8824): """Wires up a default relay on port 8824 (the default salmon log port).""" return server.Relay(hostname, port, debug=0) diff --git a/tests/salmon_tests/testing_tests.py b/tests/salmon_tests/testing_tests.py index 67564a2..c67d4f4 100644 --- a/tests/salmon_tests/testing_tests.py +++ b/tests/salmon_tests/testing_tests.py @@ -1,5 +1,3 @@ -import os - from mock import Mock, patch from nose.tools import assert_equal, with_setup @@ -10,7 +8,6 @@ delivered, queue, relay, - spelling, ) from .setup_env import setup_salmon_dirs, teardown_salmon_dirs @@ -55,13 +52,3 @@ def test_RouterConversation(): client.begin() client.say('testlist@localhost', 'This is a test') delivered('testlist@localhost'), "Test message not delivered." - - -def test_spelling(): - # specific to a mac setup, because macs are lame - if 'PYENCHANT_LIBRARY_PATH' not in os.environ: - os.environ['PYENCHANT_LIBRARY_PATH'] = '/opt/local/lib/libenchant.dylib' - - template = "tests/salmon_tests/templates/template.txt" - contents = open(template).read() - assert spelling(template, contents)