예제 #1
0
    def test_spaces_everywhere(self):
        with temp_chdir() as d:
            file = os.path.join(d, 'pip')
            File(
                'pip',
                '#!"/home/me/.local/share/hatch/venvs/a space/bin/python"\n'
                '\n'
                '# -*- coding: utf-8 -*-\n'
                'import re\n'
                'import sys\n'
                '\n'
                'from pip import main\n'
                '\n'
                "if __name__ == '__main__':\n"
                "    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])\n"
                '    sys.exit(main())\n').write(d)
            new_path = os.path.join('some', 'place', 'with spaces')
            fix_executable(file, new_path)
            updated = read_file(file)

            assert updated == (
                '#!"{}python"\n'
                '\n'
                '# -*- coding: utf-8 -*-\n'
                'import re\n'
                'import sys\n'
                '\n'
                'from pip import main\n'
                '\n'
                "if __name__ == '__main__':\n"
                "    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])\n"
                '    sys.exit(main())\n'.format(new_path + os.path.sep))
예제 #2
0
    def test_no_path(self):
        with temp_chdir() as d:
            file = os.path.join(d, 'pip')
            File('pip', '#!').write(d)
            original = read_file(file)
            fix_executable(file, d)
            updated = read_file(file)

            assert original == updated
예제 #3
0
 def test_not_file(self):
     with temp_chdir() as d:
         fix_executable(d, d)