diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2021-08-04 10:15:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-04 10:15:42 +0100 |
commit | d490d66e4b82d94b378daa9ad1e1a286e0e09258 (patch) | |
tree | 6479c740141fcd6175e13145a6c39a42240ff20d /test/test_util.py | |
parent | 70b50e068dc2496d923ee336901ed55d212fc83d (diff) | |
download | gitpython-d490d66e4b82d94b378daa9ad1e1a286e0e09258.tar.gz |
Try a better test
Diffstat (limited to 'test/test_util.py')
-rw-r--r-- | test/test_util.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/test/test_util.py b/test/test_util.py index 3058dc74..e9701f0c 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -217,8 +217,23 @@ class TestUtils(TestBase): self.assertIsInstance(Actor.author(cr), Actor) # END assure config reader is handled + @with_rw_repo('HEAD') @mock.patch("getpass.getuser") - def test_actor_get_uid_laziness_not_called(self, mock_get_uid): + def test_actor_get_uid_laziness_not_called(self, rwrepo, mock_get_uid): + with rwrepo.config_writer() as cw: + cw.set_value("user", "name", "John Config Doe") + cw.set_value("user", "email", "jcdoe@example.com") + + cr = rwrepo.config_reader() + committer = Actor.committer(cr) + author = Actor.author(cr) + + self.assertEqual(committer.name, 'John Config Doe') + self.assertEqual(committer.email, 'jcdoe@example.com') + self.assertEqual(author.name, 'John Config Doe') + self.assertEqual(author.email, 'jcdoe@example.com') + self.assertFalse(mock_get_uid.called) + env = { "GIT_AUTHOR_NAME": "John Doe", "GIT_AUTHOR_EMAIL": "jdoe@example.com", @@ -226,7 +241,7 @@ class TestUtils(TestBase): "GIT_COMMITTER_EMAIL": "jane@example.com", } os.environ.update(env) - for cr in (None, self.rorepo.config_reader()): + for cr in (None, rwrepo.config_reader()): committer = Actor.committer(cr) author = Actor.author(cr) self.assertEqual(committer.name, 'Jane Doe') @@ -241,7 +256,7 @@ class TestUtils(TestBase): committer = Actor.committer(None) author = Actor.author(None) # We can't test with `self.rorepo.config_reader()` here, as the uuid laziness - # depends on whether the user running the test has their user.name config set. + # depends on whether the user running the test has their global user.name config set. self.assertEqual(committer.name, 'user') self.assertTrue(committer.email.startswith('user@')) self.assertEqual(author.name, 'user') |