MCPcopy
hub / github.com/pytest-dev/pytest / test_gethash

Method test_gethash

testing/_py/test_local.py:574–584  ·  testing/_py/test_local.py::TestLocalPath.test_gethash
(self, tmpdir)

Source from the content-addressed store, hash-verified

572 assert tmpdir.dirpath(class="st">"/bar", abs=True) == local(class="st">"/bar")
573
574 def test_gethash(self, tmpdir):
575 from hashlib import md5
576 from hashlib import sha1 as sha
577
578 fn = tmpdir.join(class="st">"testhashfile")
579 data = bclass="st">"hello"
580 fn.write(data, mode=class="st">"wb")
581 assert fn.computehash(class="st">"md5") == md5(data).hexdigest()
582 assert fn.computehash(class="st">"sha1") == sha(data).hexdigest()
583 with pytest.raises(ValueError):
584 fn.computehash(class="st">"asdasd")
585
586 def test_remove_removes_readonly_file(self, tmpdir):
587 readonly_file = tmpdir.join(class="st">"readonly").ensure()

Callers

nothing calls this directly

Calls 3

joinMethod · 0.80
computehashMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected