Merge pull request 'Add tests for aitbc-core package (Python 3.13 fix)' (#18) from aitbc1/7-add-tests-for-aitbc-core-package into main
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (push) Has been cancelled
AITBC CI/CD Pipeline / test-cli (push) Has been cancelled
AITBC CI/CD Pipeline / test-services (push) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (push) Has been cancelled
AITBC CI/CD Pipeline / security-scan (push) Has been cancelled
AITBC CI/CD Pipeline / build (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (push) Has been cancelled
AITBC CI/CD Pipeline / performance-test (push) Has been cancelled
AITBC CI/CD Pipeline / docs (push) Has been cancelled
AITBC CI/CD Pipeline / release (push) Has been cancelled
AITBC CI/CD Pipeline / notify (push) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (push) Has been cancelled
Security Scanning / Dependency Security Scan (push) Has been cancelled
Security Scanning / Container Security Scan (push) Has been cancelled
Security Scanning / OSSF Scorecard (push) Has been cancelled
Security Scanning / Security Summary Report (push) Has been cancelled
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (push) Has been cancelled
AITBC CI/CD Pipeline / test-cli (push) Has been cancelled
AITBC CI/CD Pipeline / test-services (push) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (push) Has been cancelled
AITBC CI/CD Pipeline / security-scan (push) Has been cancelled
AITBC CI/CD Pipeline / build (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (push) Has been cancelled
AITBC CI/CD Pipeline / performance-test (push) Has been cancelled
AITBC CI/CD Pipeline / docs (push) Has been cancelled
AITBC CI/CD Pipeline / release (push) Has been cancelled
AITBC CI/CD Pipeline / notify (push) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (push) Has been cancelled
Security Scanning / Dependency Security Scan (push) Has been cancelled
Security Scanning / Container Security Scan (push) Has been cancelled
Security Scanning / OSSF Scorecard (push) Has been cancelled
Security Scanning / Security Summary Report (push) Has been cancelled
Reviewed-on: #18
This commit is contained in:
@@ -33,7 +33,12 @@ class StructuredLogFormatter(logging.Formatter):
|
|||||||
|
|
||||||
# Add exception info if present
|
# Add exception info if present
|
||||||
if record.exc_info:
|
if record.exc_info:
|
||||||
payload["exception"] = self.formatException(record.exc_info)
|
ei = record.exc_info
|
||||||
|
# In Python 3.12+, exc_info can be True to indicate lazy capture; resolve it now.
|
||||||
|
if ei is True:
|
||||||
|
ei = sys.exc_info()
|
||||||
|
if ei:
|
||||||
|
payload["exception"] = self.formatException(ei)
|
||||||
|
|
||||||
# Add stack info if present
|
# Add stack info if present
|
||||||
if record.stack_info:
|
if record.stack_info:
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ class TestStructuredLogFormatter:
|
|||||||
try:
|
try:
|
||||||
1 / 0
|
1 / 0
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
|
import sys
|
||||||
record = logging.LogRecord(
|
record = logging.LogRecord(
|
||||||
name="error.logger",
|
name="error.logger",
|
||||||
level=logging.ERROR,
|
level=logging.ERROR,
|
||||||
@@ -71,7 +72,7 @@ class TestStructuredLogFormatter:
|
|||||||
lineno=30,
|
lineno=30,
|
||||||
msg="Error occurred",
|
msg="Error occurred",
|
||||||
args=(),
|
args=(),
|
||||||
exc_info=True, # capture current exception
|
exc_info=sys.exc_info(),
|
||||||
)
|
)
|
||||||
output = formatter.format(record)
|
output = formatter.format(record)
|
||||||
data = json.loads(output)
|
data = json.loads(output)
|
||||||
|
|||||||
Reference in New Issue
Block a user