Current File : //usr/lib64/python3.6/site-packages/borg/__pycache__/selftest.cpython-36.pyc
3

y��b9�@s�dZddlZddlZddlZddlmZmZmZddlm	Z	m
Z
mZddlm
Z
ddlmZe	e
ee
egZdZGd	d
�d
e�Zdd�ZdS)
af
Self testing module
===================

The selftest() function runs a small test suite of relatively fast tests that are meant to discover issues
with the way Borg was compiled or packaged and also bugs in Borg itself.

These tests are a subset of the borg/testsuite and are run with Pythons built-in unittest, hence none of
the tests used for this can or should be ported to py.test currently.

To assert that self test discovery works correctly the number of tests is kept in the SELFTEST_COUNT
variable. SELFTEST_COUNT must be updated if new tests are added or removed to or from any of the tests
used here.
�N)�
TestResult�	TestSuite�defaultTestLoader�)�HashIndexDataTestCase�HashIndexRefcountingTestCase�HashIndexTestCase)�CryptoTestCase)�ChunkerTestCase�#cs@eZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Z�ZS)�SelfTestResultcst�j�g|_dS)N)�super�__init__�	successes)�self)�	__class__�� /usr/lib64/python3.6/selftest.pyr(s
zSelfTestResult.__init__cst�j|�|jj|�dS)N)r
�
addSuccessr�append)r�test)rrrr,szSelfTestResult.addSuccesscCs|j�pt|�S)N)ZshortDescription�str)rrrrr�	test_name0szSelfTestResult.test_namecCs`x2|j|j|jD]\}}|jd|j|�|�qWx&|jD]\}}|jd|j|�|�q<WdS)Nzself test %s FAILED:
%szself test %s skipped: %s)�errorsZfailuresZunexpectedSuccesses�errorrZskippedZwarning)r�loggerrZfailure�reasonrrr�log_results3szSelfTestResult.log_resultscCs
t|j�S)N)�lenr)rrrr�successful_test_count9sz$SelfTestResult.successful_test_count)	�__name__�
__module__�__qualname__rrrrr�
__classcell__rr)rrr's
rc	Cstjjd�dkr|jd�dStj�}t�}t�}xBtD]:}t	j
|j}dt|�ksbt
d|j��|jtj|��q8W|j|�|j|�|j�}|tk}|j�r�|r�|jd|t�|j�s�|r�|jd�t	jd�d	s�t
d
��tj�|}|jd||�dS)NZ
BORG_SELFTESTZdisabledz5borg selftest disabled via BORG_SELFTEST env variableZpytestz!pytest must not be imported in %szwself test count (%d != %d) mismatch, either test discovery is broken or a test was added without updating borg.selftestzmself test failed
Could be a bug either in Borg, the package / distribution you use, your OS or your hardware.�Fz.sanity assertion failed: ran beyond sys.exit()z'%d self tests completed in %.2f seconds)�os�environ�get�debug�timeZperf_counterrr�SELFTEST_CASES�sys�modulesr!�dir�AssertionErrorr ZaddTestrZloadTestsFromTestCaseZrunrr�SELFTEST_COUNTZ
wasSuccessfulr�exit)	rZselftest_started�resultZ
test_suiteZ	test_case�moduleZsuccessful_testsZcount_mismatchZselftest_elapsedrrr�selftest=s.





r3)�__doc__r%r+r)ZunittestrrrZtestsuite.hashindexrrrZtestsuite.cryptor	Ztestsuite.chunkerr
r*r/rr3rrrr�<module>s