Ticket #5129: py3-execfile-5129.apply-to-r34464.diff

File py3-execfile-5129.apply-to-r34464.diff, 1.6 KB (added by allenap, 4 years ago)

Tests for Java-handling code path through getExtensions, and for the "extensions" in ns branch.

  • twisted/python/test/test_dist.py

     
    88
    99import os
    1010import shutil
     11import sys
    1112
    1213from distutils.core import Distribution
    1314
     
    8889        setup.setContent(self.setupTemplate % (name,))
    8990
    9091
     92    def writeEmptySetup(self, *path):
     93        """
     94        Write out an empty C{setup.py} file to a location determined by
     95        L{self.basedir} and L{path}.
     96        """
     97        outdir = self.basedir.descendant(path)
     98        outdir.makedirs()
     99        outdir.child("setup.py").setContent("")
     100
     101
    91102    def assertExtensions(self, expected):
    92103        """
    93104        Assert that the given names match the (sorted) names of discovered
     
    127138        self.assertExtensions([])
    128139
    129140
     141    def test_getExtensionsNotSupportedOnJava(self):
     142        """
     143        Extensions are not supported on Java-based platforms.
     144        """
     145        self.addCleanup(setattr, sys, "platform", sys.platform)
     146        sys.platform = "java"
     147        self.writeSetup("twisted.sorcery", "topfiles")
     148        self.assertExtensions([])
    130149
     150
     151    def test_getExtensionsExtensionsLocalIsOptional(self):
     152        """
     153        It is acceptable for extensions to not define the C{extensions} local
     154        variable.
     155        """
     156        self.writeEmptySetup("twisted.necromancy", "topfiles")
     157        self.assertExtensions([])
     158
     159
     160
    131161class GetVersionTest(TestCase):
    132162    """
    133163    Tests for L{dist.getVersion}.