|
1 | 1 | from __future__ import print_function
|
2 | 2 |
|
| 3 | +import unittest |
3 | 4 | from unittest import TestCase
|
4 | 5 | from charmtools import utils
|
5 | 6 | from six import StringIO
|
@@ -43,3 +44,27 @@ def react(db):
|
43 | 44 | self.assertIn("Beta", output)
|
44 | 45 | self.assertIn("@when('db.ready'", output)
|
45 | 46 | self.assertIn("bar", output)
|
| 47 | + |
| 48 | + @unittest.mock.patch("os.environ") |
| 49 | + def test_host_env(self, mock_environ): |
| 50 | + mock_environ.copy.return_value = { |
| 51 | + 'PREFIX': 'fake-prefix', |
| 52 | + 'PYTHONHOME': 'fake-pythonhome', |
| 53 | + 'PYTHONPATH': 'fake-pythonpath', |
| 54 | + 'GIT_TEMPLATE_DIR': 'fake-git-template-dir', |
| 55 | + 'GIT_EXEC_PATH': 'fake-git-exec-path', |
| 56 | + 'SOME_OTHER_KEY': 'fake-some-other-key', |
| 57 | + 'PATH': '/snap/charm/current/bin:/usr/bin:' |
| 58 | + '/snap/charm/current/usr/bin:/bin', |
| 59 | + } |
| 60 | + self.assertDictEqual( |
| 61 | + {'SOME_OTHER_KEY': 'fake-some-other-key', 'PATH': '/usr/bin:/bin'}, |
| 62 | + utils.host_env()) |
| 63 | + |
| 64 | + @unittest.mock.patch.object(utils, "Process") |
| 65 | + def test_pin_setuptools_for_pep440(self, mock_Process): |
| 66 | + utils.pin_setuptools_for_pep440('/some/dir', env={'some': 'envvar'}) |
| 67 | + mock_Process.assert_called_once_with( |
| 68 | + ('/some/dir/bin/pip', 'install', '-U', 'pip<23.1', |
| 69 | + 'setuptools<67'), |
| 70 | + env={'some': 'envvar'}) |
0 commit comments