def test_yarn_install_package_json_overwrite_interactive(self):
# Testing the implied init call
stub_mod_call(self, cli)
stub_stdin(self, 'y\n')
stub_stdouts(self)
tmpdir = mkdtemp(self)
os.chdir(tmpdir)
# All the pre-made setup.
app = make_dummy_dist(self, (
('requires.txt', '\n'.join([])),
('package.json', json.dumps({
'dependencies': {'jquery': '~1.11.0'},
})),
), 'foo', '1.9.0')
working_set = WorkingSet()
working_set.add(app, self._calmjs_testing_tmpdir)
stub_item_attr_value(self, dist, 'default_working_set', working_set)
# We are going to have a fake package.json
with open(join(tmpdir, 'package.json'), 'w') as fd:
json.dump({}, fd)
# This is faked.
yarn.yarn_install('foo', overwrite=True)
with open(join(tmpdir, 'package.json')) as fd:
config = json.load(fd)
# Overwritten
self.assertEqual(config, {
'dependencies': {'jquery': '~1.11.0'},
'devDependencies': {},
'name': 'foo',
})
# No log level set.
self.assertEqual(sys.stdout.getvalue(), '')
self.assertEqual(sys.stderr.getvalue(), '')
评论列表
文章目录