Skip to content

Commit

Permalink
Organize examples tests
Browse files Browse the repository at this point in the history
Signed-off-by: elronbandel <[email protected]>
  • Loading branch information
elronbandel committed Nov 11, 2024
1 parent 944f885 commit b4a0d9f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tests/examples/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_examples(self):
# Make sure the order in which the tests are run is deterministic
# Having a different order for local testing and github testing may cause diffs in results.
times = {}
all_example_files.sort()
tested_files.sort()
failed_examples_files = []
for file in tested_files:
file_name = os.path.basename(file)
Expand All @@ -73,20 +73,22 @@ def test_examples(self):
try:
import_module_from_file(file)
logger.info(f"Testing example file: {file_name} passed")
self.assertTrue(True)
except Exception as e:
logger.error(
f"\nTesting example file: {file_name}\nFailed due to:\n{e!s}"
)
failed_examples_files.append(file)
elapsed_time = time.time() - start_time
formatted_time = str(timedelta(seconds=elapsed_time))
logger.info(
"\n_____________________________________________\n"
f" Finished testing example file:\n {file_name}\n"
f" Run Time: {formatted_time}"
"\n_____________________________________________\n"
)
times[file] = formatted_time
self.assertTrue(False)
elapsed_time = time.time() - start_time
formatted_time = str(timedelta(seconds=elapsed_time))
logger.info(
"\n_____________________________________________\n"
f" Finished testing example file:\n {file_name}\n"
f" Run Time: {formatted_time}"
"\n_____________________________________________\n"
)
times[file] = formatted_time
logger.critical("Example run time:")
print_dict(times, log_level="critical")
if len(failed_examples_files) > 0:
Expand Down

0 comments on commit b4a0d9f

Please sign in to comment.