예제 #1
0
    def test_build_ext(self):
        support.copy_xxmodule_c(self.tmp_dir)
        xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
        xx_ext = Extension('xx', [xx_c])
        dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]})
        dist.package_dir = self.tmp_dir
        cmd = build_ext(dist)
        support.fixup_build_ext(cmd)
        cmd.build_lib = self.tmp_dir
        cmd.build_temp = self.tmp_dir
        cmd.ensure_finalized()
        cmd.run()

        code = textwrap.dedent("""\
            import sys
            sys.path.insert(0, %r)

            import xx

            for attr in ('error', 'foo', 'new', 'roj'):
                assert hasattr(xx, attr)

            assert xx.foo(2, 5) == 7
            assert xx.foo(13, 15) == 28
            assert xx.new().demo() is None
            doc = 'This is a template module just for instruction.'
            assert xx.__doc__ == doc
            assert isinstance(xx.Null(), xx.Null)
            assert isinstance(xx.Str(), xx.Str)
            """)
        code = code % self.tmp_dir
        assert_python_ok('-c', code)
    def test_build_ext(self):
        support.copy_xxmodule_c(self.tmp_dir)
        xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
        xx_ext = Extension('xx', [xx_c])
        dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]})
        dist.package_dir = self.tmp_dir
        cmd = build_ext(dist)
        support.fixup_build_ext(cmd)
        cmd.build_lib = self.tmp_dir
        cmd.build_temp = self.tmp_dir
        cmd.ensure_finalized()
        cmd.run()

        code = textwrap.dedent("""\
            import sys
            sys.path.insert(0, %r)

            import xx

            for attr in ('error', 'foo', 'new', 'roj'):
                assert hasattr(xx, attr)

            assert xx.foo(2, 5) == 7
            assert xx.foo(13, 15) == 28
            assert xx.new().demo() is None
            doc = 'This is a template module just for instruction.'
            assert xx.__doc__ == doc
            assert isinstance(xx.Null(), xx.Null)
            assert isinstance(xx.Str(), xx.Str)
            """)
        code = code % self.tmp_dir
        assert_python_ok('-c', code)
예제 #3
0
    def test_generate_setup_py(self):
        os.chdir(self.mkdtemp())
        self.write_file('setup.cfg', textwrap.dedent("""\
            [metadata]
            name = SPAM
            classifier = Programming Language :: Python
            """))
        generate_setup_py()
        self.assertTrue(os.path.exists('setup.py'), 'setup.py not created')
        rc, out, err = assert_python_ok('setup.py', '--name')
        self.assertEqual(out, 'SPAM\n')
        self.assertEqual(err, '')

        # a generated setup.py should complain if no setup.cfg is present
        os.unlink('setup.cfg')
        rc, out, err = assert_python_failure('setup.py', '--name')
        self.assertIn('setup.cfg', err)
예제 #4
0
 def call_pysetup(self, *args):
     _, out, err = assert_python_ok('-m', 'distutils2.run', *args,
                                    PYTHONPATH=self.get_pythonpath())
     return out, err
예제 #5
0
 def call_pysetup(self, *args):
     _, out, err = assert_python_ok('-m',
                                    'distutils2.run',
                                    *args,
                                    PYTHONPATH=self.get_pythonpath())
     return out, err