관리-도구
편집 파일: doctests.cpython-37.pyc
B 0�SeFD � @ s\ d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m Z ddlmZm Z mZmZmZmZmZ yddlmZ W n ek r� ddlmZ Y nX ddlZddlZe�e�ZyddlZej W n* eefk r� ddlm m Z Y nX ej!Z"G dd � d e"�Z#e#e_!G d d� dej$�Z%G dd � d e�Z&G dd� dej�ZG dd� dej'�Z'dS )a� Use the Doctest plugin with ``--with-doctest`` or the NOSE_WITH_DOCTEST environment variable to enable collection and execution of :mod:`doctests <doctest>`. Because doctests are usually included in the tested package (instead of being grouped into packages or modules of their own), nose only looks for them in the non-test packages it discovers in the working directory. Doctests may also be placed into files other than python modules, in which case they can be collected and executed by using the ``--doctest-extension`` switch or NOSE_DOCTEST_EXTENSION environment variable to indicate which file extension(s) to load. When loading doctests from non-module files, use the ``--doctest-fixtures`` switch to specify how to find modules containing fixtures for the tests. A module name will be produced by appending the value of that switch to the base name of each doctest file loaded. For example, a doctest file "widgets.rst" with the switch ``--doctest_fixtures=_fixt`` will load fixtures from the module ``widgets_fixt.py``. A fixtures module may define any or all of the following functions: * setup([module]) or setup_module([module]) Called before the test runs. You may raise SkipTest to skip all tests. * teardown([module]) or teardown_module([module]) Called after the test runs, if setup/setup_module did not raise an unhandled exception. * setup_test(test) Called before the test. NOTE: the argument passed is a doctest.DocTest instance, *not* a unittest.TestCase. * teardown_test(test) Called after the test, if setup_test did not raise an exception. NOTE: the argument passed is a doctest.DocTest instance, *not* a unittest.TestCase. Doctests are run like any other test, with the exception that output capture does not work; doctest does its own output capture while running a test. .. note :: See :doc:`../doc_tests/test_doctest_fixtures/doctest_fixtures` for additional documentation and examples. � N)� getmodule)�Plugin)�ContextList)�anyp� getpackage�test_address�resolve_name�src�tolist� isproperty)�StringIOc @ s$ e Zd Zdd� Zdd� Zdd� ZdS )�NoseOutputRedirectingPdbc C s d| _ t�| |� d S )NF)�(_NoseOutputRedirectingPdb__debugger_used�_orp�__init__)�self�out� r �F/opt/alt/python37/lib/python3.7/site-packages/nose/plugins/doctests.pyr Z s z!NoseOutputRedirectingPdb.__init__c C s d| _ t�| t�� j� d S )NT)r r � set_trace�sys� _getframe�f_back)r r r r r ^ s z"NoseOutputRedirectingPdb.set_tracec C s | j rt�| � d S )N)r r �set_continue)r r r r r b s z%NoseOutputRedirectingPdb.set_continueN)�__name__� __module__�__qualname__r r r r r r r r Y s r c @ s6 e Zd ZdZdZd dd�Zdd� Zd d � Zdd� ZdS )�DoctestSuitea� Doctest suites are parallelizable at the module or file level only, since they may be attached to objects that are not individually addressable (like properties). This suite subclass is used when loading doctests from a module to ensure that behavior. This class is used only if the plugin is not fully prepared; in normal use, the loader's suiteClass is used. Fr Nc C s || _ || _tjj| |d� d S )N)�tests)�context� can_split�unittest� TestSuiter )r r r r r r r r w s zDoctestSuite.__init__c C s t | j�S )N)r r )r r r r �address| s zDoctestSuite.addressc C s t | j�S )N)�iter�_tests)r r r r �__iter__ s zDoctestSuite.__iter__c C s t | j�S )N)�strr% )r r r r �__str__� s zDoctestSuite.__str__)r NF) r r r �__doc__r r r# r&