<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
h                 @   s   d Z ddlZddlZyddlZW n ek
r<   ddlZY nX yddlZW n ek
rf   ddlZY nX G dd dejZG dd dej	Z
eedre
ZejZnej	Zdd	 ZdS )
a[  A subclass of unittest.TestCase which checks for reference leaks.

To use:
- Use testing_refleak.BaseTestCase instead of unittest.TestCase
- Configure and compile Python with --with-pydebug

If sys.gettotalrefcount() is not available (because Python was built without
the Py_DEBUG option), then this module is a no-op and tests will run normally.
    Nc               @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )LocalTestResultzHA TestResult which forwards events to a parent object, except for Skips.c             C   s   t jj|  || _d S )N)unittest
TestResult__init__parent_result)selfr    r   &/usr/lib/python3.6/testing_refleaks.pyr   :   s    zLocalTestResult.__init__c             C   s   | j j|| d S )N)r   addError)r   testerrorr   r   r	   r
   >   s    zLocalTestResult.addErrorc             C   s   | j j|| d S )N)r   
addFailure)r   r   r   r   r   r	   r   A   s    zLocalTestResult.addFailurec             C   s   d S )Nr   )r   r   reasonr   r   r	   addSkipD   s    zLocalTestResult.addSkipN)__name__
__module____qualname____doc__r   r
   r   r   r   r   r   r	   r   7   s
   r   c                   s.   e Zd ZdZdZd fdd	Zdd Z  ZS )	ReferenceLeakCheckerTestCasezHA TestCase which runs tests multiple times, collecting reference counts.   Nc                s   t jj | _tt| j|d tt| j|d d}t|}g }xBt| j	D ]4}| j
 }tt| j|d | j
 }|j||  qLW t|| f y| j|dg| j	  W n$ tk
r   |j| tj  Y nX d S )N)resultr   )copyregdispatch_tablecopy_saved_pickle_registrysuperr   runr   rangeNB_RUNS_getRefcountsappendprintZassertEqual	Exceptionr
   sysexc_info)r   r   ZoldrefcountZlocal_resultZrefcount_deltas_Znewrefcount)	__class__r   r	   r   M   s     z ReferenceLeakCheckerTestCase.runc             C   s8   t jj  t jj| j tj  tj  tj  tj S )N)	r   r   clearupdater   gcZcollectr#   gettotalrefcount)r   r   r   r	   r   g   s    
z*ReferenceLeakCheckerTestCase._getRefcounts)N)r   r   r   r   r   r   r   __classcell__r   r   )r&   r	   r   H   s   r   r*   c             C   s   ~ dd }|S )Nc             S   s   | S )Nr   )funcr   r   r	   Same|   s    z&SkipReferenceLeakChecker.<locals>.Samer   )r   r-   r   r   r	   SkipReferenceLeakCheckerz   s    r.   )r   r)   r#   r   ImportErrorZ	unittest2r   r   r   ZTestCaser   hasattrZBaseTestCaseskipr.   r   r   r   r	   <module>'   s"   *
