@@ -22,7 +22,8 @@ def test_describe_tag_and_patch(mock_repo):
22
22
23
23
repo = GitRepo ('./' , mock_repo )
24
24
25
- assert expected == repo .commit .describe ('12345' )
25
+ with patch ('git.repo.fun.name_to_object' ):
26
+ assert expected == repo .commit .describe ('12345' )
26
27
27
28
28
29
def test_describe_tag_only (mock_repo ):
@@ -37,7 +38,8 @@ def test_describe_tag_only(mock_repo):
37
38
38
39
repo = GitRepo ('./' , mock_repo )
39
40
40
- assert expected == repo .commit .describe ('12345' )
41
+ with patch ('git.repo.fun.name_to_object' ):
42
+ assert expected == repo .commit .describe ('12345' )
41
43
42
44
43
45
def test_describe_empty (mock_repo ):
@@ -52,7 +54,8 @@ def test_describe_empty(mock_repo):
52
54
53
55
repo = GitRepo ('./' , mock_repo )
54
56
55
- assert expected == repo .commit .describe ('12345' )
57
+ with patch ('git.repo.fun.name_to_object' ):
58
+ assert expected == repo .commit .describe ('12345' )
56
59
57
60
58
61
def test_describe_sha_doesnt_exist (mock_repo ):
@@ -62,10 +65,25 @@ def test_describe_sha_doesnt_exist(mock_repo):
62
65
THEN a ReferenceNotFoundException is raised
63
66
"""
64
67
repo = GitRepo ('./' , mock_repo )
68
+
69
+ with patch ('git.repo.fun.name_to_object' ) as mock_name_to_object :
70
+ mock_name_to_object .side_effect = git .exc .BadName ()
71
+ with pytest .raises (exceptions .ReferenceNotFoundException ):
72
+ repo .commit .describe ('doesntexist' )
73
+
74
+
75
+ def test_describe_sha_with_describe_failure (mock_repo ):
76
+ """
77
+ GIVEN GitRepo initialized with a path and repo
78
+ WHEN git.describe fails
79
+ THEN a DescribeException is raised
80
+ """
81
+ repo = GitRepo ('./' , mock_repo )
65
82
repo .git .describe .side_effect = git .CommandError ('describe' )
66
83
67
- with pytest .raises (exceptions .DescribeException ):
68
- repo .commit .describe ('12345' )
84
+ with patch ('git.repo.fun.name_to_object' ):
85
+ with pytest .raises (exceptions .DescribeException ):
86
+ repo .commit .describe ('12345' )
69
87
70
88
71
89
def test_describe_with_lightweight_tags (mock_repo ):
@@ -81,7 +99,8 @@ def test_describe_with_lightweight_tags(mock_repo):
81
99
82
100
repo = GitRepo ('./' , mock_repo )
83
101
84
- assert expected == repo .commit .describe ('12345' )
102
+ with patch ('git.repo.fun.name_to_object' ):
103
+ assert expected == repo .commit .describe ('12345' )
85
104
86
105
87
106
def test_commit (mock_repo ):
0 commit comments