File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,6 +124,18 @@ returned by the constructors:
124124
125125 The internal block size of the hash algorithm in bytes.
126126
127+ A hash object has the following attributes:
128+
129+ .. attribute :: hash.name
130+
131+ The canonical name of this hash, always lowercase and always suitable as a
132+ parameter to :func: `new ` to create another hash of this type.
133+
134+ .. versionchanged :: 3.4
135+ The name attribute has been present in CPython since its inception, but
136+ until Python 3.4 was not formally specified, so may not exist on some
137+ platforms.
138+
127139A hash object has the following methods:
128140
129141
Original file line number Diff line number Diff line change @@ -154,6 +154,11 @@ def test_hexdigest(self):
154154 assert isinstance (h .digest (), bytes ), name
155155 self .assertEqual (hexstr (h .digest ()), h .hexdigest ())
156156
157+ def test_name_attribute (self ):
158+ for cons in self .hash_constructors :
159+ h = cons ()
160+ assert isinstance (h .name , str ), "No name attribute"
161+ assert h .name in self .supported_hash_names
157162
158163 def test_large_update (self ):
159164 aas = b'a' * 128
You can’t perform that action at this time.
0 commit comments