| Total Complexity | 3 | 
| Total Lines | 21 | 
| Duplicated Lines | 0 % | 
| Changes | 16 | ||
| Bugs | 3 | Features | 1 | 
| 1 | from __future__ import unicode_literals | ||
| 16 | class Test(CLITestCase): | ||
| 17 | def test_write_env(self): | ||
| 18 | tmpdir = tempfile.mkdtemp() | ||
| 19 | self.addCleanup(shutil.rmtree, tmpdir) | ||
| 20 | |||
| 21 |         with mock.patch('binstar_client.commands.config.USER_CONFIG', join(tmpdir, 'config.yaml')), \ | ||
| 22 |              mock.patch('binstar_client.commands.config.SEARCH_PATH', [tmpdir]): | ||
| 23 | main(['config', '--set', 'url', 'http://localhost:5000'], False) | ||
| 24 | |||
| 25 | self.assertTrue(exists(join(tmpdir, 'config.yaml'))) | ||
| 26 | |||
| 27 | with open(join(tmpdir, 'config.yaml')) as f: | ||
| 28 | config_output = f.read() | ||
| 29 | expected_config_output = 'url: http://localhost:5000\n' | ||
| 30 | self.assertEqual(config_output, expected_config_output) | ||
| 31 | |||
| 32 | main(['config', '--show-sources'], False) | ||
| 33 |             expected_show_sources_output = '==> {config} <==\nurl: http://localhost:5000\n\n'.format( | ||
| 34 | config=join(tmpdir, 'config.yaml')) | ||
| 35 | |||
| 36 | self.assertIn(expected_show_sources_output, self.stream.getvalue()) | ||
| 37 |