| Server IP : 121.121.20.254 / Your IP : 216.73.217.51 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Python315/Lib/test/__pycache__/ |
Upload File : |
R
>lqj� c �� � ] PH s ] PHs] PHs] QHGs \ \ Q2 sQs, P1Q ks\O \Q2 Q Q\O 2 2 s\Q6X c \O 2 P! P! ) � )�
script_helper� _stats_ona
import sys
import threading
import time
THREADS = 2
class A:
pass
class B:
pass
def modify_class():
# This is used as a rare event we can assume doesn't happen unless we do it.
# It increments the "Rare event (set_class)" count.
a = A()
a.__class__ = B
TURNED_ON = False
def stats_on():
global TURNED_ON
sys._stats_on()
TURNED_ON = True
TURNED_OFF = False
def stats_off():
global TURNED_OFF
sys._stats_off()
TURNED_OFF = True
CLEARED = False
def stats_clear():
global CLEARED
sys._stats_clear()
CLEARED = True
def func_start():
pass
def func_end():
pass
def func_test(thread_id):
pass
_TEST_CODE_
func_start()
threads = []
for i in range(THREADS):
t = threading.Thread(target=func_test, args=(i,))
threads.append(t)
t.start()
for t in threads:
t.join()
func_end()
c � � [ O [ 2 oUO Q[ O U 2 2 oUQU,* oS9% f - o[ O
U- U@ v qVUO O QQ2 oUO Q2 F D1 oQU7 f J UO Q2 v q�o
U
O 2 t ! P! )zIRun test code and return the value of the "set_class" stats counter.
�_TEST_CODE_z-c�ascii�backslashreplace�
zRare event (set_class)�:)�textwrap�dedent�
TEST_TEMPLATE�replacer �run_python_until_end�err�decode�split� partition�strip)� test_code�args�env_vars�code�script_args�res�_�stderr�line�label�values &&& �&C:\Python315\\Lib\test\test_pystats.py�
run_test_coder E s� � � �?�?�=�)�D��<�<�
�x���y�'A�B�D��$���%�K��~�~�2�H�
�
/�
/��
I��
I�F�C�
�W�W�^�^�G�%7�
8�F����T�"��#�t�+�"�n�n�S�1�O�E�e��;�;�=� � #� � zrequires pystats build optionc �D ` � \ sQ s]Ys n QsQ sQ sQ sQ sQ s Qs
U sP! )�TestPyStatszJTests for pystats functionality (requires --enable-pystats build
option).
c � � Qo[ UQQ,Q5 oU O UQ2 [ UQQ-Q5 oU O UQ2 [ U2 oU O UP2 Qo[ U2 oU O UQ2 P! ) z+Check the toggle on functionality.
z>
def func_start():
modify_class()
�-X�pystats�r �1�PYTHONSTATS)r zu
def func_start():
modify_class()
sys._stats_on()
modify_class()
�r �assertEqual��selfr �
stat_counts & r �test_stats_toggle_on� TestPyStats.test_stats_toggle_on_ s� � ��� #�4�t�Y�.?�@�
�����S�)� #�4�=�#�2F�G�
�����S�)� #�4�(�
�����R�(��� #�4�(�
�����S�)r! c � � Qo[ U2 oU O UQ2 Qo[ UQQ,Q5 oU O UQ2 P! )zACheck the toggle on functionality when threads are used.
a
def func_test(thread_id):
if thread_id == 0:
modify_class()
stats_on()
modify_class()
else:
while not TURNED_ON:
pass
modify_class()
�2a
def func_test(thread_id):
if thread_id == 0:
modify_class()
stats_off()
modify_class()
else:
while not TURNED_OFF:
pass
modify_class()
r% r&