Skip to content

Commit 3a300a6

Browse files
committed
run test on itself; allow multple suffixes
1 parent 5164467 commit 3a300a6

3 files changed

Lines changed: 40 additions & 9 deletions

File tree

additional_dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,7 @@ param
15001500
parameterisation
15011501
parameterization
15021502
params
1503+
parsers
15031504
partitioner
15041505
partitioners
15051506
parzen

codespell.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ def splitCamelCase(word):
3838

3939
def getMimeType(filepath):
4040

41-
suffix2mime = {'.h': 'text/x-c++', '.py': 'text/x-python',
42-
'.ruby': 'test/x-ruby',
43-
'.java': 'text/x-java-source'}
41+
suffix2mime = { '.h': 'text/x-c++',
42+
'.cxx': 'text/x-c++',
43+
'.c': 'text/x-c++',
44+
'.py': 'text/x-python',
45+
'.ruby': 'test/x-ruby',
46+
'.java': 'text/x-java-source'
47+
}
4448
name, ext = os.path.splitext(filepath)
4549
return suffix2mime[ext]
4650

@@ -174,7 +178,7 @@ def parse_args():
174178
parser.add_argument('--miss', '-m', action='store_true', default=False,
175179
dest='miss', help='Only output the misspelt words')
176180

177-
parser.add_argument('--suffix', '-s', action='store', default=".h",
181+
parser.add_argument('--suffix', '-s', action='append', default=[".h"],
178182
dest='suffix', help='File name suffix')
179183

180184
args = parser.parse_args()
@@ -228,6 +232,10 @@ def main():
228232

229233
bad_words = []
230234

235+
if output_lvl>1:
236+
print("Prefixes:", prefixes)
237+
print("Suffixes:", args.suffix)
238+
231239
for f in file_list:
232240

233241
if not args.miss:
@@ -236,7 +244,12 @@ def main():
236244
if os.path.isdir(f):
237245

238246
# f is a directory, so search for files inside
239-
dir_entries = glob.glob(f + '/**/*' + args.suffix, recursive=True)
247+
dir_entries = []
248+
for s in args.suffix:
249+
dir_entries = dir_entries + glob.glob(f + '/**/*' + s, recursive=True)
250+
251+
if output_lvl:
252+
print(dir_entries)
240253

241254
# spell check the files found in f
242255
for x in dir_entries:

tests/test_codespell.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
class TestCodespell(unittest.TestCase):
77
@classmethod
88
def setUpClass(self):
9-
print("Setting up codespell tests")
9+
print("\nSetting up codespell tests")
1010

1111
@classmethod
1212
def tearDownClass(cls):
13-
print("Tearing down dicom2stl tests")
13+
print("\nTearing down dicom2stl tests")
1414

1515
def test_codespell(self):
16-
print("Codespell test")
16+
print("\nCodespell simple test")
1717
cwd = os.getcwd()
1818
print(cwd)
1919
runresult = subprocess.run(
@@ -28,6 +28,23 @@ def test_codespell(self):
2828
)
2929
print("Return code:", runresult.returncode)
3030
if runresult.returncode:
31-
self.fail("codespell process returned bad code")
31+
self.fail("Simple test: codespell process returned bad code")
32+
33+
print("\nCodespell test on itself")
34+
cwd = os.getcwd()
35+
print(cwd)
36+
runresult = subprocess.run(
37+
[
38+
"python",
39+
"codespell.py",
40+
"--verbose",
41+
"--suffix",
42+
".py",
43+
"."
44+
]
45+
)
46+
print("Return code:", runresult.returncode)
47+
if runresult.returncode:
48+
self.fail("Self code test: codespell process returned bad code")
3249

3350

0 commit comments

Comments
 (0)