|
8 | 8 | import tempfile
|
9 | 9 | import getpass
|
10 | 10 |
|
11 |
| -import pytest |
12 |
| - |
13 | 11 | from mock import Mock
|
14 |
| -import pip |
15 | 12 |
|
16 | 13 | from pip.locations import distutils_scheme
|
17 | 14 |
|
@@ -77,86 +74,6 @@ def get_mock_getpwuid(self, uid):
|
77 | 74 | result.pw_name = self.username
|
78 | 75 | return result
|
79 | 76 |
|
80 |
| - def get_build_dir_location(self): |
81 |
| - """ returns a string pointing to the |
82 |
| - current build_prefix. |
83 |
| - """ |
84 |
| - return os.path.join(self.tempdir, 'pip_build_%s' % self.username) |
85 |
| - |
86 |
| - def test_dir_path(self): |
87 |
| - """ test the path name for the build_prefix |
88 |
| - """ |
89 |
| - from pip import locations |
90 |
| - assert locations._get_build_prefix() == self.get_build_dir_location() |
91 |
| - |
92 |
| - # skip on windows, build dir is not created |
93 |
| - @pytest.mark.skipif("sys.platform == 'win32'") |
94 |
| - @pytest.mark.skipif("not hasattr(os, 'O_NOFOLLOW')") |
95 |
| - def test_dir_created(self): |
96 |
| - """ test that the build_prefix directory is generated when |
97 |
| - _get_build_prefix is called. |
98 |
| - """ |
99 |
| - assert not os.path.exists(self.get_build_dir_location()), \ |
100 |
| - "the build_prefix directory should not exist yet!" |
101 |
| - from pip import locations |
102 |
| - locations._get_build_prefix() |
103 |
| - assert os.path.exists(self.get_build_dir_location()), \ |
104 |
| - "the build_prefix directory should now exist!" |
105 |
| - |
106 |
| - # skip on windows, build dir is not created |
107 |
| - @pytest.mark.skipif("sys.platform == 'win32'") |
108 |
| - def test_dir_created_without_NOFOLLOW(self, monkeypatch): |
109 |
| - """ test that the build_prefix directory is generated when |
110 |
| - os.O_NOFOLLOW doen't exist |
111 |
| - """ |
112 |
| - if hasattr(os, 'O_NOFOLLOW'): |
113 |
| - monkeypatch.delattr("os.O_NOFOLLOW") |
114 |
| - assert not os.path.exists(self.get_build_dir_location()), \ |
115 |
| - "the build_prefix directory should not exist yet!" |
116 |
| - from pip import locations |
117 |
| - locations._get_build_prefix() |
118 |
| - assert os.path.exists(self.get_build_dir_location()), \ |
119 |
| - "the build_prefix directory should now exist!" |
120 |
| - |
121 |
| - # skip on windows; this exception logic only runs on linux |
122 |
| - @pytest.mark.skipif("sys.platform == 'win32'") |
123 |
| - @pytest.mark.skipif("not hasattr(os, 'O_NOFOLLOW')") |
124 |
| - def test_error_raised_when_owned_by_another(self): |
125 |
| - """ test calling _get_build_prefix when there is a temporary |
126 |
| - directory owned by another user raises an InstallationError. |
127 |
| - """ |
128 |
| - from pip import locations |
129 |
| - os.geteuid = lambda: 1111 |
130 |
| - os.mkdir(self.get_build_dir_location()) |
131 |
| - |
132 |
| - with pytest.raises(pip.exceptions.InstallationError): |
133 |
| - locations._get_build_prefix() |
134 |
| - |
135 |
| - # skip on windows; this exception logic only runs on linux |
136 |
| - @pytest.mark.skipif("sys.platform == 'win32'") |
137 |
| - def test_error_raised_when_owned_by_another_without_NOFOLLOW( |
138 |
| - self, monkeypatch): |
139 |
| - """ test calling _get_build_prefix when there is a temporary |
140 |
| - directory owned by another user raises an InstallationError. |
141 |
| - (when os.O_NOFOLLOW doesn't exist |
142 |
| - """ |
143 |
| - if hasattr(os, 'O_NOFOLLOW'): |
144 |
| - monkeypatch.delattr("os.O_NOFOLLOW") |
145 |
| - from pip import locations |
146 |
| - os.geteuid = lambda: 1111 |
147 |
| - os.mkdir(self.get_build_dir_location()) |
148 |
| - |
149 |
| - with pytest.raises(pip.exceptions.InstallationError): |
150 |
| - locations._get_build_prefix() |
151 |
| - |
152 |
| - def test_no_error_raised_when_owned_by_you(self): |
153 |
| - """ test calling _get_build_prefix when there is a temporary |
154 |
| - directory owned by you raise no InstallationError. |
155 |
| - """ |
156 |
| - from pip import locations |
157 |
| - os.mkdir(self.get_build_dir_location()) |
158 |
| - locations._get_build_prefix() |
159 |
| - |
160 | 77 |
|
161 | 78 | class TestDisutilsScheme:
|
162 | 79 |
|
|
0 commit comments