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   {