Server IP : 172.67.216.182 / Your IP : 172.70.208.119 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/twisted/python/test/ |
Upload File : |
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Tests for L{twisted.python._pydoctor}. """ from twisted.python.reflect import requireModule from twisted.trial.unittest import TestCase model = requireModule("pydoctor.model") pydoctorSkip = None TwistedSphinxInventory = object TwistedSystem = object if model is None: pydoctorSkip = "Pydoctor is not present." else: # We have a valid pydoctor. from twisted.python._pydoctor import TwistedSphinxInventory, TwistedSystem class TwistedSystemTests(TestCase): """ Tests for L{TwistedSystem}. """ skip = pydoctorSkip def test_initCustomSphinxInventory(self): """ After initialization it has a custom C{intersphinx} member. """ sut = TwistedSystem() self.assertIsInstance(sut.intersphinx, TwistedSphinxInventory) def test_privacyClassBaseTestPackage(self): """ The base I{twisted.test} package is visible to allow traversal to a few selected test API which is visible. """ sut = TwistedSystem() twistedPackage = model.Package( system=sut, name="twisted", parent=None, ) twistedTestPackage = model.Package( system=sut, name="test", parent=twistedPackage, ) result = sut.privacyClass(twistedTestPackage) self.assertIs(result, model.PrivacyClass.VISIBLE) def test_privacyClassProtoHelpers(self): """ The I{twisted.test.proto_helpers} module is visible. """ sut = TwistedSystem() twistedPackage = model.Package( system=sut, name="twisted", parent=None, ) twistedTestPackage = model.Package( system=sut, name="test", parent=twistedPackage, ) twistedProtoHelpersModule = model.Module( system=sut, name="proto_helpers", parent=twistedTestPackage, ) result = sut.privacyClass(twistedProtoHelpersModule) self.assertIs(result, model.PrivacyClass.VISIBLE) def test_privacyClassChildTestModule(self): """ Any child of the I{twisted.test} package is hidden. """ sut = TwistedSystem() twistedPackage = model.Package( system=sut, name="twisted", parent=None, ) twistedTestPackage = model.Package( system=sut, name="test", parent=twistedPackage, ) twistedAnyTestModule = model.Module( system=sut, name="other_child", parent=twistedTestPackage, ) result = sut.privacyClass(twistedAnyTestModule) self.assertIs(result, model.PrivacyClass.HIDDEN) def test_privacyClassPublicCode(self): """ Any child of the I{twisted} package has a privacy according to the general rules defined in pydoctor. """ sut = TwistedSystem() twistedPackage = model.Package( system=sut, name="twisted", parent=None, ) twistedSubProjectPackage = model.Package( system=sut, name="subproject", parent=twistedPackage, ) twistedSubProjectModule = model.Module( system=sut, name="other_child", parent=twistedSubProjectPackage, ) twistedPrivateModule = model.Module( system=sut, name="_private_child", parent=twistedSubProjectPackage, ) result = sut.privacyClass(twistedSubProjectPackage) self.assertIs(result, model.PrivacyClass.VISIBLE) result = sut.privacyClass(twistedSubProjectModule) self.assertIs(result, model.PrivacyClass.VISIBLE) result = sut.privacyClass(twistedPrivateModule) self.assertIs(result, model.PrivacyClass.PRIVATE) class TwistedSphinxInventoryTests(TestCase): """ Tests for L{TwistedSphinxInventory}. """ skip = pydoctorSkip def getInventoryWithZope(self): """ Initialized a pre-loaded inventory. @return: A new inventory which already has a few I{zope.interface} inter sphinx links loaded. @rtype: L{TwistedSphinxInventory} """ inventory = TwistedSphinxInventory(logger=object(), project_name="Super Duper") zopeBaseURL = "https://zope.tld" zopeAPIURL = "api.html#$" inventory._links.update( { "zope.interface.interfaces.IInterface": (zopeBaseURL, zopeAPIURL), "zope.interface.declarations.implementer": (zopeBaseURL, zopeAPIURL), } ) return inventory def test_getLinkExistentInInterSphinx(self): """ Return the full URL based on pre-loaded inter sphinx objects. """ sut = self.getInventoryWithZope() result = sut.getLink("zope.interface.interfaces.IInterface") self.assertEqual( "https://zope.tld/api.html#zope.interface.interfaces.IInterface", result ) def test_getLinkZopeNonExistent(self): """ Any reference to I{zope.interface} which is not in the inter sphinx database returns L{None}. """ sut = self.getInventoryWithZope() # Interface is at zope.interface.interfaces.IInterface so using the # short name will fail to find the url. result = sut.getLink("zope.interface.Interface") self.assertIsNone(result) # Any unknown reference returns None. result = sut.getLink("zope.interface.NoSuchReference") self.assertIsNone(result) def test_getLinkZopeAdapterRegistry(self): """ 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. """ sut = self.getInventoryWithZope() result = sut.getLink("zope.interface.adapter.AdapterRegistry") self.assertEqual("https://zope.tld/adapter.html", result)