Skip to content

Commit

Permalink
Merge branch 'master' into pr-143
Browse files Browse the repository at this point in the history
  • Loading branch information
PonteIneptique committed Jul 1, 2019
2 parents 7d4f451 + 517cae2 commit 1d8c689
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
17 changes: 10 additions & 7 deletions HookTest/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,11 @@ def run(self):

self.text_files, self.cts_files = self.find()
self.start()
# We deal with Inventory files first to get a list of urns

# We deal with Inventory files first to get a list of urns
with Pool(processes=self.workers) as executor:
# We iterate over a dictionary of completed tasks
for future in executor.imap_unordered(self.unit, [file for file in self.cts_files]):
# We iterate over the list of files, checking them in parallel.
for future in executor.imap_unordered(self.unit, self.cts_files):
result, filepath, additional = future
self.results[filepath] = result
self.passing[filepath] = result.status
Expand All @@ -416,10 +416,9 @@ def run(self):
executor.join()
self.middle() # To print the results from the metadata file tests

# We load a thread pool which has 5 maximum workers
# Now deal with the text files.
with Pool(processes=self.workers) as executor:
# We create a dictionary of tasks which
for future in executor.imap_unordered(self.unit, [file for file in self.text_files]):
for future in executor.imap_unordered(self.unit, self.text_files):
result, filepath, additional = future
self.results[filepath] = result
self.passing[filepath] = result.status
Expand Down Expand Up @@ -617,7 +616,11 @@ def end(self):
dtds=dtd_errors,
empts=empty_refs))
t_pass = num_texts - num_failed
cov = round(statistics.mean([test.coverage for test in self.results.values()]), ndigits=2)
cov_results = [test.coverage for test in self.results.values()]
if cov_results:
cov = round(statistics.mean(cov_results), ndigits=2)
else:
cov = 0.00
results_table = PT(["HookTestResults", ""])
results_table.align["HookTestResults", ""] = "c"
results_table.hrules = pt_all
Expand Down
27 changes: 26 additions & 1 deletion tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def hooktest(self, args):
..note:: See https://wrongsideofmemphis.wordpress.com/2010/03/01/store-standard-output-on-a-variable-in-python/
:param args: List of commandline arguments
:return: Sys stdout, status
:return: status, output_string
"""
# Store the reference, in case you want to show things again in standard output
old_stdout = sys.stdout
Expand Down Expand Up @@ -570,3 +570,28 @@ def test_run_local_greek_count_word_raise(self):
"Word Counting", logs,
"Word Counting should not be there"
)

def test_run_emptyDir(self):
"""Test a run against an empty directory.
Should fail but not assert."""
status, logs = self.hooktest([
"./tests/emptyDir", "--console", "--verbose"
])
self.assertLogResult(
logs, "Total Texts", "0",
"No texts should have been found"
)
self.assertLogResult(
logs, "Passing Texts", "0",
"No texts should have passed"
)
self.assertLogResult(
logs, "Metadata Files", "0",
"No metadata should have been found"
)
self.assertLogResult(
logs, "Passing Metadata", "0",
"No metadata should have passed"
)
self.assertEqual(status, "error", "Should error with no files")

0 comments on commit 1d8c689

Please sign in to comment.