1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
"""Pytest configuration and fixtures for Python tests
This module provides fixtures and configuration to handle cleanup
and prevent segfaults during pytest teardown.
"""
# Track library instances to ensure proper cleanup
=
"""Cleanup function to explicitly shut down library instances"""
global
# Try to shut down gracefully
# Ignore errors during cleanup - Python may be finalizing
pass
# Register cleanup function
"""
Minimal cleanup fixture - avoid aggressive cleanup that can trigger segfaults.
The segfault is happening during pytest's teardown phase, so we avoid
doing anything that might interfere with pytest's cleanup process.
"""
yield
# Don't do anything - let pytest and Python handle cleanup naturally
# Aggressive cleanup can trigger segfaults during teardown
"""Track a library instance for cleanup"""
global
return
"""Configure pytest to handle segfaults gracefully"""
# Set up signal handlers if possible
"""Handle SIGSEGV gracefully"""
# Don't exit immediately - let pytest finish its cleanup
# Exit with segfault code
# Only register handler on Linux/Unix
# Signal handling not available or failed - continue without it
pass
"""
Handle pytest session finish - check if tests passed even if exit code is 139
This hook allows us to override the exit status if tests passed but cleanup segfaulted.
"""
# If exit status is 139 (segfault) but tests passed, we can override it
# Check if any tests actually failed
=
# Note: We can't actually change exitstatus here, but we can log it
# The CI workflow will handle this
return
return