@@ -69,8 +69,26 @@ def test_util_image_name_get_repo(self, image_string, dictionary):
6969
7070 def test_util_image_name_to_str (self , image_string , dictionary ):
7171 image = ImageName .parse (image_string )
72- assert image .to_str () == (image_string .lstrip ('/' ) if image_string else None )
73- assert image .to_str (explicit_tag = True ) == image_string .lstrip ('/' ) + (':latest' if dictionary ["tag" ] is None else "" )
72+ if dictionary ["repo" ] is None :
73+ with pytest .raises (RuntimeError ):
74+ image .to_str ()
75+ else :
76+ assert image .to_str () == image_string .lstrip ('/' )
77+ assert image .to_str () == (image_string .lstrip ('/' ) if image_string else None )
78+ assert image .to_str (explicit_tag = True ) == \
79+ image_string .lstrip ('/' ) + (':latest' if dictionary ["tag" ] is None else "" )
80+
81+ def test_image_name_hash (self , image_string , dictionary ):
82+ image = ImageName .parse (image_string )
83+ if dictionary ["repo" ] is None :
84+ with pytest .raises (RuntimeError ):
85+ hash (image )
86+ else :
87+ hash (image )
88+
89+ def test_image_name_repr (self , image_string , dictionary ):
90+ image = ImageName .parse (image_string )
91+ repr (image )
7492
7593 def test_image_name_comparison (self , image_string , dictionary ):
7694 # make sure that "==" is implemented correctly on both Python major releases
@@ -120,11 +138,6 @@ def test_image_name_enclose(repo, organization, enclosed_repo, registry, tag):
120138 assert image_name .registry == registry
121139 assert image_name .tag == tag
122140
123- def test_image_name_hash ():
124- hash (ImageName ("Hello" ))
125-
126- def test_image_name_repr ():
127- repr (ImageName ("World" ))
128141
129142class TestDockerfileParser (object ):
130143 def test_all_versions_match (self ):
0 commit comments