Skip to content

Commit d490d66

Browse files
authored
Try a better test
1 parent 70b50e0 commit d490d66

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

‎test/test_util.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,31 @@ def test_actor(self):
217217
self.assertIsInstance(Actor.author(cr), Actor)
218218
# END assure config reader is handled
219219

220+
@with_rw_repo('HEAD')
220221
@mock.patch("getpass.getuser")
221-
def test_actor_get_uid_laziness_not_called(self, mock_get_uid):
222+
def test_actor_get_uid_laziness_not_called(self, rwrepo, mock_get_uid):
223+
with rwrepo.config_writer() as cw:
224+
cw.set_value("user", "name", "John Config Doe")
225+
cw.set_value("user", "email", "jcdoe@example.com")
226+
227+
cr = rwrepo.config_reader()
228+
committer = Actor.committer(cr)
229+
author = Actor.author(cr)
230+
231+
self.assertEqual(committer.name, 'John Config Doe')
232+
self.assertEqual(committer.email, 'jcdoe@example.com')
233+
self.assertEqual(author.name, 'John Config Doe')
234+
self.assertEqual(author.email, 'jcdoe@example.com')
235+
self.assertFalse(mock_get_uid.called)
236+
222237
env = {
223238
"GIT_AUTHOR_NAME": "John Doe",
224239
"GIT_AUTHOR_EMAIL": "jdoe@example.com",
225240
"GIT_COMMITTER_NAME": "Jane Doe",
226241
"GIT_COMMITTER_EMAIL": "jane@example.com",
227242
}
228243
os.environ.update(env)
229-
for cr in (None, self.rorepo.config_reader()):
244+
for cr in (None, rwrepo.config_reader()):
230245
committer = Actor.committer(cr)
231246
author = Actor.author(cr)
232247
self.assertEqual(committer.name, 'Jane Doe')
@@ -241,7 +256,7 @@ def test_actor_get_uid_laziness_called(self, mock_get_uid):
241256
committer = Actor.committer(None)
242257
author = Actor.author(None)
243258
# We can't test with `self.rorepo.config_reader()` here, as the uuid laziness
244-
# depends on whether the user running the test has their user.name config set.
259+
# depends on whether the user running the test has their global user.name config set.
245260
self.assertEqual(committer.name, 'user')
246261
self.assertTrue(committer.email.startswith('user@'))
247262
self.assertEqual(author.name, 'user')

0 commit comments

Comments
 (0)