Exemplo n.º 1
0
    def test_2to3_user_mode(self, test_env):
        settings = dict(
            name='foo',
            packages=['foo'],
            use_2to3=True,
            version='0.0',
        )
        dist = Distribution(settings)
        dist.script_name = 'setup.py'
        cmd = develop(dist)
        cmd.user = 1
        cmd.ensure_finalized()
        cmd.install_dir = site.USER_SITE
        cmd.user = 1
        with contexts.quiet():
            cmd.run()

        # let's see if we got our egg link at the right place
        content = os.listdir(site.USER_SITE)
        content.sort()
        assert content == ['easy-install.pth', 'foo.egg-link']

        # Check that we are using the right code.
        fn = os.path.join(site.USER_SITE, 'foo.egg-link')
        with io.open(fn) as egg_link_file:
            path = egg_link_file.read().split()[0].strip()
        fn = os.path.join(path, 'foo', '__init__.py')
        with io.open(fn) as init_file:
            init = init_file.read().strip()

        expected = 'print("foo")' if six.PY3 else 'print "foo"'
        assert init == expected
Exemplo n.º 2
0
    def test_develop(self):
        if sys.version < "2.6" or hasattr(sys, 'real_prefix'):
            return
        dist = Distribution(
            dict(name='foo',
                 packages=['foo'],
                 use_2to3=True,
                 version='0.0',
                 ))
        dist.script_name = 'setup.py'
        cmd = develop(dist)
        cmd.user = 1
        cmd.ensure_finalized()
        cmd.install_dir = site.USER_SITE
        cmd.user = 1
        old_stdout = sys.stdout
        #sys.stdout = StringIO()
        try:
            cmd.run()
        finally:
            sys.stdout = old_stdout

        # let's see if we got our egg link at the right place
        content = os.listdir(site.USER_SITE)
        content.sort()
        self.assertEqual(content, ['easy-install.pth', 'foo.egg-link'])

        # Check that we are using the right code.
        path = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt').read().split()[0].strip()
        init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip()
        if sys.version < "3":
            self.assertEqual(init, 'print "foo"')
        else:
            self.assertEqual(init, 'print("foo")')
Exemplo n.º 3
0
    def test_develop(self):
        if sys.version < "2.6" or hasattr(sys, 'real_prefix'):
            return
        dist = Distribution(
            dict(name='foo',
                 packages=['foo'],
                 use_2to3=True,
                 version='0.0',
                 ))
        dist.script_name = 'setup.py'
        cmd = develop(dist)
        cmd.user = 1
        cmd.ensure_finalized()
        cmd.install_dir = site.USER_SITE
        cmd.user = 1
        old_stdout = sys.stdout
        #sys.stdout = StringIO()
        try:
            cmd.run()
        finally:
            sys.stdout = old_stdout

        # let's see if we got our egg link at the right place
        content = os.listdir(site.USER_SITE)
        content.sort()
        self.assertEqual(content, ['easy-install.pth', 'foo.egg-link'])

        # Check that we are using the right code.
        path = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt').read().split()[0].strip()
        init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip()
        if sys.version < "3":
            self.assertEqual(init, 'print "foo"')
        else:
            self.assertEqual(init, 'print("foo")')
Exemplo n.º 4
0
    def test_develop(self):
        if sys.version < "2.6":
            return
        dist = Distribution()
        dist.script_name = 'setup.py'
        cmd = develop(dist)
        cmd.user = 1
        cmd.ensure_finalized()
        cmd.user = 1
        old_stdout = sys.stdout
        sys.stdout = StringIO()
        try:
            cmd.run()
        finally:
            sys.stdout = old_stdout

        # let's see if we got our egg link at the right place
        content = os.listdir(site.USER_SITE)
        content.sort()
        self.assertEquals(content, ['UNKNOWN.egg-link', 'easy-install.pth'])
Exemplo n.º 5
0
    def test_develop(self):
        if sys.version < "2.6":
            return
        dist = Distribution()
        dist.script_name = "setup.py"
        cmd = develop(dist)
        cmd.user = 1
        cmd.ensure_finalized()
        cmd.user = 1
        old_stdout = sys.stdout
        sys.stdout = StringIO()
        try:
            cmd.run()
        finally:
            sys.stdout = old_stdout

        # let's see if we got our egg link at the right place
        content = os.listdir(site.USER_SITE)
        content.sort()
        self.assertEquals(content, ["UNKNOWN.egg-link", "easy-install.pth"])
    def test_develop(self):
        if sys.version < "2.6" or hasattr(sys, 'real_prefix'):
            return
        dist = Distribution()
        dist.script_name = 'setup.py'
        cmd = develop(dist)
        cmd.user = 1
        cmd.ensure_finalized()
        cmd.install_dir = site.USER_SITE
        cmd.user = 1
        old_stdout = sys.stdout
        sys.stdout = StringIO()
        try:
            cmd.run()
        finally:
            sys.stdout = old_stdout

        # let's see if we got our egg link at the right place
        content = os.listdir(site.USER_SITE)
        content.sort()
        self.assertEquals(content, ['UNKNOWN.egg-link', 'easy-install.pth'])
Exemplo n.º 7
0
 def test_console_scripts(self, tmpdir):
     """
     Test that console scripts are installed and that they reference
     only the project by name and not the current version.
     """
     pytest.skip("TODO: needs a fixture to cause 'develop' "
         "to be invoked without mutating environment.")
     settings = dict(
         name='foo',
         packages=['foo'],
         version='0.0',
         entry_points={
             'console_scripts': [
                 'foocmd = foo:foo',
             ],
         },
     )
     dist = Distribution(settings)
     dist.script_name = 'setup.py'
     cmd = develop(dist)
     cmd.ensure_finalized()
     cmd.install_dir = tmpdir
     cmd.run()
Exemplo n.º 8
0
 def test_console_scripts(self, tmpdir):
     """
     Test that console scripts are installed and that they reference
     only the project by name and not the current version.
     """
     pytest.skip("TODO: needs a fixture to cause 'develop' "
                 "to be invoked without mutating environment.")
     settings = dict(
         name='foo',
         packages=['foo'],
         version='0.0',
         entry_points={
             'console_scripts': [
                 'foocmd = foo:foo',
             ],
         },
     )
     dist = Distribution(settings)
     dist.script_name = 'setup.py'
     cmd = develop(dist)
     cmd.ensure_finalized()
     cmd.install_dir = tmpdir
     cmd.run()
Exemplo n.º 9
0
    def test_develop(self):
        if hasattr(sys, "real_prefix"):
            return
        dist = Distribution(dict(name="foo", packages=["foo"], use_2to3=True, version="0.0"))
        dist.script_name = "setup.py"
        cmd = develop(dist)
        cmd.user = 1
        cmd.ensure_finalized()
        cmd.install_dir = site.USER_SITE
        cmd.user = 1
        old_stdout = sys.stdout
        # sys.stdout = StringIO()
        try:
            cmd.run()
        finally:
            sys.stdout = old_stdout

        # let's see if we got our egg link at the right place
        content = os.listdir(site.USER_SITE)
        content.sort()
        assert content == ["easy-install.pth", "foo.egg-link"]

        # Check that we are using the right code.
        egg_link_file = open(os.path.join(site.USER_SITE, "foo.egg-link"), "rt")
        try:
            path = egg_link_file.read().split()[0].strip()
        finally:
            egg_link_file.close()
        init_file = open(os.path.join(path, "foo", "__init__.py"), "rt")
        try:
            init = init_file.read().strip()
        finally:
            init_file.close()
        if sys.version < "3":
            assert init == 'print "foo"'
        else:
            assert init == 'print("foo")'
Exemplo n.º 10
0
    def test_develop(self):
<<<<<<< HEAD
        if hasattr(sys, 'real_prefix'):
=======
        if sys.version < "2.6" or hasattr(sys, 'real_prefix'):
>>>>>>> e4baf504ede925f4f1e07d823c9b20b3d0dbe14c
            return
        dist = Distribution(
            dict(name='foo',
                 packages=['foo'],
                 use_2to3=True,
                 version='0.0',
                 ))
        dist.script_name = 'setup.py'
        cmd = develop(dist)
        cmd.user = 1
        cmd.ensure_finalized()
        cmd.install_dir = site.USER_SITE
        cmd.user = 1
        old_stdout = sys.stdout
        #sys.stdout = StringIO()
        try:
            cmd.run()
        finally:
            sys.stdout = old_stdout

        # let's see if we got our egg link at the right place
        content = os.listdir(site.USER_SITE)
        content.sort()
<<<<<<< HEAD