o
    ¯bF  ã                   @   sr   d Z ddlmZ ddlmZ edƒZdZeZeZ	edu rdZnddl
mZm	Z	 G dd	„ d	eƒZG d
d„ deƒZdS )z(
Tests for L{twisted.python._pydoctor}.
é    )ÚrequireModule)ÚTestCasezpydoctor.modelNzPydoctor is not present.)ÚTwistedSphinxInventoryÚTwistedSystemc                   @   s<   e Zd ZdZeZdd„ Zdd„ Zdd„ Zdd	„ Z	d
d„ Z
dS )ÚTwistedSystemTestsz%
    Tests for L{TwistedSystem}.
    c                 C   s   t ƒ }|  |jt¡ dS )zM
        After initialization it has a custom C{intersphinx} member.
        N)r   ÚassertIsInstanceÚintersphinxr   )ÚselfÚsut© r   úC/usr/lib/python3/dist-packages/twisted/python/test/test_pydoctor.pyÚtest_initCustomSphinxInventory   s   z1TwistedSystemTests.test_initCustomSphinxInventoryc                 C   sD   t ƒ }tj|ddd�}tj|d|d�}| |¡}|  |tjj¡ dS )z…
        The base I{twisted.test} package is visible to allow traversal to a
        few selected test API which is visible.
        ÚtwistedN©ÚsystemÚnameÚparentÚtest)r   ÚmodelÚPackageÚprivacyClassÚassertIsÚPrivacyClassÚVISIBLE)r	   r
   ÚtwistedPackageÚtwistedTestPackageÚresultr   r   r   Ú test_privacyClassBaseTestPackage$   s   ýý
z3TwistedSystemTests.test_privacyClassBaseTestPackagec                 C   óT   t ƒ }tj|ddd�}tj|d|d�}tj|d|d�}| |¡}|  |tjj¡ dS )zF
        The I{twisted.test.proto_helpers} module is visible.
        r   Nr   r   Úproto_helpers)r   r   r   ÚModuler   r   r   r   )r	   r
   r   r   ÚtwistedProtoHelpersModuler   r   r   r   Útest_privacyClassProtoHelpers9   ó$   ýýý
z0TwistedSystemTests.test_privacyClassProtoHelpersc                 C   r   )zE
        Any child of the I{twisted.test} package is hidden.
        r   Nr   r   Úother_child)r   r   r   r    r   r   r   ÚHIDDEN)r	   r
   r   r   ÚtwistedAnyTestModuler   r   r   r   Ú test_privacyClassChildTestModuleR   r#   z3TwistedSystemTests.test_privacyClassChildTestModulec                 C   s˜   t ƒ }tj|ddd�}tj|d|d�}tj|d|d�}tj|d|d�}| |¡}|  |tjj¡ | |¡}|  |tjj¡ | |¡}|  |tjj¡ dS )z
        Any child of the I{twisted} package has a privacy according to the
        general rules defined in pydoctor.
        r   Nr   Ú
subprojectr$   Ú_private_child)	r   r   r   r    r   r   r   r   ÚPRIVATE)r	   r
   r   ÚtwistedSubProjectPackageÚtwistedSubProjectModuleÚtwistedPrivateModuler   r   r   r   Útest_privacyClassPublicCodek   s6   ýýýý


z.TwistedSystemTests.test_privacyClassPublicCodeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚpydoctorSkipÚskipr   r   r"   r'   r.   r   r   r   r   r      s    r   c                   @   s4   e Zd ZdZeZdd„ Zdd„ Zdd„ Zdd	„ Z	d
S )ÚTwistedSphinxInventoryTestsz.
    Tests for L{TwistedSphinxInventory}.
    c                 C   s4   t tƒ dd�}d}d}|j ||f||fdœ¡ |S )zÒ
        Initialized a pre-loaded inventory.

        @return: A new inventory which already has a few I{zope.interface}
            inter sphinx links loaded.
        @rtype: L{TwistedSphinxInventory}
        zSuper Duper)ÚloggerÚproject_namezhttps://zope.tldz
api.html#$)ú$zope.interface.interfaces.IInterfacez'zope.interface.declarations.implementer)r   ÚobjectÚ_linksÚupdate)r	   Ú	inventoryÚzopeBaseURLÚ
zopeAPIURLr   r   r   ÚgetInventoryWithZope—   s   þÿz0TwistedSphinxInventoryTests.getInventoryWithZopec                 C   ó"   |   ¡ }| d¡}|  d|¡ dS )zO
        Return the full URL based on pre-loaded inter sphinx objects.
        r8   z>https://zope.tld/api.html#zope.interface.interfaces.IInterfaceN©r?   ÚgetLinkÚassertEqual©r	   r
   r   r   r   r   Ú!test_getLinkExistentInInterSphinx¬   s
   
ÿz=TwistedSphinxInventoryTests.test_getLinkExistentInInterSphinxc                 C   s4   |   ¡ }| d¡}|  |¡ | d¡}|  |¡ dS )zw
        Any reference to I{zope.interface} which is not in the inter sphinx
        database returns L{None}.
        zzope.interface.Interfacezzope.interface.NoSuchReferenceN)r?   rB   ÚassertIsNonerD   r   r   r   Útest_getLinkZopeNonExistent¸   s
   


z7TwistedSphinxInventoryTests.test_getLinkZopeNonExistentc                 C   r@   )z¤
        I{zope.interface.adapter.AdapterRegistry} is a special case for which
        the link the narrative docs is returned as there is no API docs yet.
        z&zope.interface.adapter.AdapterRegistryzhttps://zope.tld/adapter.htmlNrA   rD   r   r   r   Útest_getLinkZopeAdapterRegistryÇ   s   
z;TwistedSphinxInventoryTests.test_getLinkZopeAdapterRegistryN)
r/   r0   r1   r2   r3   r4   r?   rE   rG   rH   r   r   r   r   r5   �   s    r5   )r2   Útwisted.python.reflectr   Útwisted.trial.unittestr   r   r3   r9   r   r   Útwisted.python._pydoctorr   r5   r   r   r   r   Ú<module>   s   {