MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_config_file_command_key

Method test_config_file_command_key

Lib/test/test_venv.py:171–202  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

169 self.assertTrue(os.path.exists(fn), 'File %r should exist.' % fn)
170
171 def test_config_file_command_key(self):
172 options = [
173 (None, None, None), # Default case.
174 ('--copies', 'symlinks', False),
175 ('--without-pip', 'with_pip', False),
176 ('--system-site-packages', 'system_site_packages', True),
177 ('--clear', 'clear', True),
178 ('--upgrade', 'upgrade', True),
179 ('--upgrade-deps', 'upgrade_deps', True),
180 ('--prompt="foobar"', 'prompt', 'foobar'),
181 ('--without-scm-ignore-files', 'scm_ignore_files', frozenset()),
182 ]
183 for opt, attr, value in options:
184 with self.subTest(opt=opt, attr=attr, value=value):
185 rmtree(self.env_dir)
186 if not attr:
187 kwargs = {}
188 else:
189 kwargs = {attr: value}
190 b = venv.EnvBuilder(**kwargs)
191 b.upgrade_dependencies = Mock() # avoid pip command to upgrade deps
192 b._setup_pip = Mock() # avoid pip setup
193 self.run_with_capture(b.create, self.env_dir)
194 data = self.get_text_file_contents('pyvenv.cfg')
195 if not attr or opt.endswith('git'):
196 for opt in ('--system-site-packages', '--clear', '--upgrade',
197 '--upgrade-deps', '--prompt'):
198 self.assertNotRegex(data, rf'command = .* {opt}')
199 elif os.name=='nt' and attr=='symlinks':
200 pass
201 else:
202 self.assertRegex(data, rf'command = .* {opt}')
203
204 def test_prompt(self):
205 env_name = os.path.split(self.env_dir)[1]

Callers

nothing calls this directly

Calls 8

rmtreeFunction · 0.90
MockClass · 0.90
subTestMethod · 0.80
run_with_captureMethod · 0.80
assertNotRegexMethod · 0.80
assertRegexMethod · 0.80
endswithMethod · 0.45

Tested by

no test coverage detected