From e9d8629cd950fb92f2d951a1517e1d5a09d2d74b Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 17 Jun 2016 16:07:11 -0400 Subject: [PATCH] FIX: Fix command --- bin/codespell.py | 2 +- codespell_lib/tests/test_basic.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/bin/codespell.py b/bin/codespell.py index 0142a97c12..7e4f59f155 100755 --- a/bin/codespell.py +++ b/bin/codespell.py @@ -4,4 +4,4 @@ if __name__ == '__main__': import codespell_lib - sys.exit(codespell_lib.main(*sys.argv)) + sys.exit(codespell_lib.main(*sys.argv[1:])) diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py index ca4c1f5d6c..05d2fe9693 100644 --- a/codespell_lib/tests/test_basic.py +++ b/codespell_lib/tests/test_basic.py @@ -5,6 +5,7 @@ import contextlib import os import os.path as op +import subprocess import sys import tempfile import warnings @@ -14,6 +15,23 @@ from codespell_lib import main +def run_codespell(args=(), cwd=None): + """Helper to run codespell""" + return subprocess.Popen( + ['codespell.py'] + list(args), cwd=cwd, + stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait() + + +def test_command(): + """Test running codespell.py""" + # With no arguments does "." + with TemporaryDirectory() as d: + assert_equal(run_codespell(cwd=d), 0) + with open(op.join(d, 'bad.txt'), 'w') as f: + f.write('abandonned\nAbandonned\nABANDONNED\nAbAnDoNnEd') + assert_equal(run_codespell(cwd=d), 4) + + def test_basic(): """Test some basic functionality""" assert_equal(main('_does_not_exist_'), 0)