function main_v67
Test runner function that executes a suite of regional format handling tests for CSV parsing, including European and US number formats with various delimiters.
/tf/active/vicechatdev/vice_ai/test_regional_formats.py
186 - 210
simple
Purpose
This function serves as the main entry point for a test suite that validates CSV parsing functionality across different regional formats. It sequentially runs tests for European CSV (comma as decimal separator), US CSV (period as decimal separator), formats with thousands separators, and tab-delimited files. The function provides formatted console output showing test progress and results, returning 0 for success or 1 for failure.
Source Code
def main():
print("\n" + "="*60)
print("Regional Format Handling Tests")
print("="*60)
try:
test_european_csv()
test_us_csv()
test_european_with_thousands()
test_us_with_thousands()
test_tab_delimited_european()
print("\n" + "="*60)
print("ā ALL TESTS PASSED!")
print("="*60 + "\n")
return 0
except AssertionError as e:
print(f"\nā TEST FAILED: {e}\n")
return 1
except Exception as e:
print(f"\nā ERROR: {e}\n")
import traceback
traceback.print_exc()
return 1
Return Value
Returns an integer exit code: 0 if all tests pass successfully, 1 if any test fails (either through AssertionError or any other Exception). This follows standard Unix convention for process exit codes.
Dependencies
pandaspathlibtraceback
Required Imports
import os
import sys
import pandas as pd
from pathlib import Path
from smartstat_service import smart_read_csv
from smartstat_service import convert_european_decimals
Conditional/Optional Imports
These imports are only needed under specific conditions:
import traceback
Condition: only when an exception occurs during test execution
Required (conditional)Usage Example
if __name__ == '__main__':
exit_code = main()
sys.exit(exit_code)
Best Practices
- This function should be called as the main entry point of the test script
- The return value should be used as the process exit code to indicate test success/failure to CI/CD systems
- All test functions called by main() must be defined before calling main()
- Test functions should raise AssertionError for test failures to be properly caught and reported
- The function provides clear visual feedback with separator lines and status symbols (ā and ā)
- Error handling includes full traceback printing for debugging unexpected exceptions
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function test_european_csv 73.6% similar
-
function test_european_with_thousands 71.1% similar
-
function test_tab_delimited_european 70.5% similar
-
function test_us_csv 67.7% similar
-
function test_us_with_thousands 66.4% similar