Skip to content

Commit

Permalink
0.6.15
Browse files Browse the repository at this point in the history
  • Loading branch information
joocer committed Oct 5, 2023
1 parent 0ba2636 commit f28ec9d
Show file tree
Hide file tree
Showing 44 changed files with 174 additions and 187 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/regression_suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
--blobHost 0.0.0.0
- name: Run Regression Tests
run: coverage run -m pytest
run: coverage run -m pytest -color=yes
env:
MINIO_END_POINT: 127.0.0.1:9000
MINIO_ACCESS_KEY: minioadmin
Expand Down
74 changes: 74 additions & 0 deletions tests/helpers/runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
def run_tests():
import contextlib
import inspect
from io import StringIO
import shutil
import time
import traceback

display_width = shutil.get_terminal_size((80, 20))[0]

# Get the calling module
caller_module = inspect.getmodule(inspect.currentframe().f_back)
test_methods = []
for name, obj in inspect.getmembers(caller_module):
if inspect.isfunction(obj) and name.startswith("test_"):
test_methods.append(obj)

print(f"\n\033[38;2;139;233;253m\033[3mRUNNING SET OF {len(test_methods)} TESTS\033[0m\n")
start_suite = time.monotonic_ns()

passed = 0
failed = 0

for index, method in enumerate(test_methods):
start_time = time.monotonic_ns()
test_name = f"\033[38;2;255;184;108m{(index + 1):04}\033[0m \033[38;2;189;147;249m{str(method.__name__)}\033[0m"
print(test_name.ljust(display_width - 20), end="")
error = None
output = ""
try:
stdout = StringIO() # Create a StringIO object
with contextlib.redirect_stdout(stdout):
method()
output = stdout.getvalue()
except Exception as err:
error = err
finally:
if error is None:
passed += 1
status = "\033[38;2;26;185;67m pass"
else:
failed += 1
status = f"\033[38;2;255;121;198m fail"
time_taken = int((time.monotonic_ns() - start_time) / 1e6)
print(f"\033[0;32m{str(time_taken).rjust(8)}ms {status}\033[0m")
if error:
traceback_details = traceback.extract_tb(error.__traceback__)
file_name, line_number, function_name, code_line = traceback_details[-1]
file_name = file_name.split("/")[-1]
print(
f" \033[38;2;255;121;198m{error.__class__.__name__}\033[0m"
+ f" {error}\n"
+ f" \033[38;2;241;250;140m{file_name}\033[0m"
+ f"\033[38;2;98;114;164m:\033[0m"
+ f"\033[38;2;26;185;67m{line_number}\033[0m"
+ f" \033[38;2;98;114;164m{code_line}\033[0m"
)
if output:
print(
"\033[38;2;98;114;164m"
+ "=" * display_width
+ "\033[0m"
+ output.strip()
+ "\n"
+ "\033[38;2;98;114;164m"
+ "=" * display_width
+ "\033[0m"
)

print(
f"\n\033[38;2;139;233;253m\033[3mCOMPLETE\033[0m ({((time.monotonic_ns() - start_suite) / 1e9):.2f} seconds)\n"
f" \033[38;2;26;185;67m{passed} passed ({(passed * 100) // (passed + failed)}%)\033[0m\n"
f" \033[38;2;255;121;198m{failed} failed\033[0m"
)
5 changes: 2 additions & 3 deletions tests/test_data_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def test_group_by():


if __name__ == "__main__": # pragma: no cover
test_group_by()
test_group_by_advanced()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
21 changes: 4 additions & 17 deletions tests/test_data_dictset.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,7 @@ def test_sort():
], st


if __name__ == "__main__":
test_count()
test_enumeration()
test_sample()
test_repr()
test_collect()
test_keys()
test_distinct()
test_types()
test_summary()
test_take()
test_items()
test_filters()
test_hash()
test_sort()

print("OKAY")
if __name__ == "__main__": # pragma: no cover
from tests.helpers.runner import run_tests

run_tests()
6 changes: 3 additions & 3 deletions tests/test_data_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_html_table():
assert "</table>" in html


if __name__ == "__main__":
test_html_table()
if __name__ == "__main__": # pragma: no cover
from tests.helpers.runner import run_tests

print("OKAY")
run_tests()
6 changes: 2 additions & 4 deletions tests/test_data_group_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ def test_gappy_set():


if __name__ == "__main__": # pragma: no cover
test_group_by()
test_combined_group_by()
test_gappy_set()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
19 changes: 3 additions & 16 deletions tests/test_data_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,19 +262,6 @@ def test_validator_other():


if __name__ == "__main__": # pragma: no cover
test_validator_all_valid_values()
test_validator_invalid_string()
test_validator_invalid_number()
test_validator_invalid_schema()
test_validator_invalid_boolean()
test_validator_nonnative_types()
test_validator_extended_schema()
test_validator_loaders()
test_validator_list()
test_validator_datetime()
test_unknown_type()
test_raise_exception()
test_call_alias()
test_validator_other()

print("okay")
from tests.helpers.runner import run_tests

run_tests()
4 changes: 2 additions & 2 deletions tests/test_error_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ def test_error_stack():


if __name__ == "__main__": # pragma: no cover
test_error_stack()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
6 changes: 2 additions & 4 deletions tests/test_index_data_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ def test_index_types():


if __name__ == "__main__": # pragma: no cover
test_data_index()
test_complex_indexes()
test_index_types()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
7 changes: 2 additions & 5 deletions tests/test_log_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ def test_sanitizing_log_formatter_predefined_redaction_keys():


if __name__ == "__main__": # pragma: no cover
test_sanitizing_log_formatter_pass_thru()
test_sanitizing_log_formatter_redact_simple_case()
test_sanitizing_log_formatter_mixed_redact_and_keep()
test_sanitizing_log_formatter_predefined_redaction_keys()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
8 changes: 4 additions & 4 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
set_log_name(LOG_NAME)


def test_new_log_levels(caplog):
def test_new_log_levels(caplog=None):
"""
caplog is a feature of pytest that allows logs to be captured and
inspected.
Expand Down Expand Up @@ -85,6 +85,6 @@ def test_log_sanitizer():


if __name__ == "__main__": # pragma: no cover
test_smoke_test()
test_log_sanitizer()
test_new_log_levels(None)
from tests.helpers.runner import run_tests

run_tests()
4 changes: 3 additions & 1 deletion tests/test_logging_gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ def test_google_logging():


if __name__ == "__main__": # pragma: no cover
test_google_logging()
from tests.helpers.runner import run_tests

run_tests()
6 changes: 2 additions & 4 deletions tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ def test_reader_can_read_alot():


if __name__ == "__main__": # pragma: no cover
test_reader_can_read()
test_reader_to_pandas()
test_reader_can_read_alot()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
11 changes: 3 additions & 8 deletions tests/test_reader_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ def test_short_dates():


if __name__ == "__main__": # pragma: no cover
test_start_date_only()
test_end_date_only()
test_start_and_end_dates()
test_dates_as_string()
test_short_dates()
test_reading_across_dates()

print("okay")
from tests.helpers.runner import run_tests

run_tests()
7 changes: 2 additions & 5 deletions tests/test_reader_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ def test_as():


if __name__ == "__main__": # pragma: no cover
test_simple_fields()
test_simple_functions()
test_concat()
test_as()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
7 changes: 2 additions & 5 deletions tests/test_reader_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ def test_simple_compound_expressions():


if __name__ == "__main__": # pragma: no cover
test_expression_compilation()
test_simple_equals_expressions()
test_simple_not_expressions()
test_simple_compound_expressions()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
12 changes: 3 additions & 9 deletions tests/test_reader_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ def test_combined_filters():


if __name__ == "__main__": # pragma: no cover
test_reader_filters_no_filter()
test_reader_filters_single_filter()
test_reader_filters_multiple_filter()
test_filters()
test_empty_filters()
test_like_filters()
test_combined_filters()

print("okay")
from tests.helpers.runner import run_tests

run_tests()
5 changes: 2 additions & 3 deletions tests/test_reader_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def test_reader_can_read_zipped_csv():


if __name__ == "__main__": # pragma: no cover
test_reader_can_read_csv()
test_reader_can_read_zipped_csv()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
4 changes: 2 additions & 2 deletions tests/test_reader_hours.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ def test_reader_times():


if __name__ == "__main__": # pragma: no cover
test_reader_times()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
5 changes: 2 additions & 3 deletions tests/test_reader_ignore_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def test_ignore_flag_step_back_days():


if __name__ == "__main__": # pragma: no cover
test_ignore_flag()
test_ignore_flag_step_back_days()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
5 changes: 2 additions & 3 deletions tests/test_reader_inline_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def test_inline_other():


if __name__ == "__main__": # pragma: no cover
test_inline_date_functions()
test_inline_other()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
5 changes: 2 additions & 3 deletions tests/test_reader_partitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def test_reader_partitions_read_referring_to_specific_partition():


if __name__ == "__main__": # pragma: no cover
test_reader_partitions_read_without_referring_to_partition()
test_reader_partitions_read_referring_to_specific_partition()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
8 changes: 3 additions & 5 deletions tests/test_reader_sql_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ def test_from_validator():
SqlParser.validate_dataset(None, "this--is--not--okay")


if __name__ == "__main__":
test_parser()
test_invalid_sql()
test_from_validator()
if __name__ == "__main__": # pragma: no cover
from tests.helpers.runner import run_tests

print("complete")
run_tests()
13 changes: 2 additions & 11 deletions tests/test_reader_sql_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,6 @@ def test_group_by_count():


if __name__ == "__main__": # pragma: no cover
import mabel
from tests.helpers.runner import run_tests

print(mabel.__version__)

test_sql_returned_rows()
test_sql_to_dictset()
test_sql_returned_cols()
test_where()
test_limit()
test_group_by_count()

print("okay")
run_tests()
6 changes: 2 additions & 4 deletions tests/test_reader_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ def test_levenshtein():


if __name__ == "__main__": # pragma: no cover
test_reader_all_good()
test_dataset_prefix_validator()
test_levenshtein()
from tests.helpers.runner import run_tests

print("okay")
run_tests()
4 changes: 3 additions & 1 deletion tests/test_test_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ def test_mock():


if __name__ == "__main__": # pragma: no cover
test_mock()
from helpers.runner import run_tests

run_tests()
Loading

0 comments on commit f28ec9d

Please sign in to comment.