Exemplo n.º 1
0
    def test_find_package_modules(self):
        """
        Will filter the found modules excluding the modules listed in
        L{twisted.python.dist3}.
        """
        distribution = Distribution()
        distribution.script_name = "setup.py"
        distribution.script_args = "build_py"
        builder = BuildPy3(distribution)

        # Rig the dist3 data so that we can reduce the scope of this test and
        # reduce the risk of getting false failures, while doing a minimum
        # level of patching.
        self.patch(
            _setup,
            "notPortedModules",
            [
                "twisted.spread.test.test_pbfailure",
            ],
        )
        twistedPackageDir = filepath.FilePath(twisted.__file__).parent()
        packageDir = twistedPackageDir.child("spread").child("test")

        result = builder.find_package_modules("twisted.spread.test", packageDir.path)

        self.assertEqual(
            sorted(
                [
                    (
                        "twisted.spread.test",
                        "__init__",
                        packageDir.child("__init__.py").path,
                    ),
                    (
                        "twisted.spread.test",
                        "test_banana",
                        packageDir.child("test_banana.py").path,
                    ),
                    (
                        "twisted.spread.test",
                        "test_jelly",
                        packageDir.child("test_jelly.py").path,
                    ),
                    (
                        "twisted.spread.test",
                        "test_pb",
                        packageDir.child("test_pb.py").path,
                    ),
                ]
            ),
            sorted(result),
        )
Exemplo n.º 2
0
    def test_find_package_modules(self):
        """
        Will filter the found modules including only the modules listed in
        L{twisted.python.dist3}.
        """
        distribution = Distribution()
        distribution.script_name = 'setup.py'
        distribution.script_args = 'build_py'
        builder = BuildPy3(distribution)

        # Rig the dist3 data so that we can reduce the scope of this test and
        # reduce the risk of getting false failures, while doing a minimum
        # level of patching.
        self.patch(
            dist3,
            'modulesToInstall',
            [
                "twisted.spread.banana",
                "twisted.test.__init__",
                "twisted.test.iosim",
                "twisted.test.test_abstract",
            ],
        )
        self.patch(
            dist3,
            'testDataFiles',
            [
                "twisted.python.test.pullpipe",
                "twisted.test.mock_win32process",
            ],
        )
        twistedPackageDir = filepath.FilePath(twisted.__file__).parent()
        packageDir = twistedPackageDir.child("test")

        result = builder.find_package_modules('twisted.test', packageDir.path)

        self.assertEqual(
            sorted([
                ('twisted.test', 'test_abstract',
                 packageDir.child('test_abstract.py').path),
                ('twisted.test', '__init__',
                 packageDir.child('__init__.py').path),
                ('twisted.test', 'iosim', packageDir.child('iosim.py').path),
                ('twisted.test', 'mock_win32process',
                 packageDir.child('mock_win32process.py').path),
            ]),
            sorted(result),
        )