mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
tests the download function in _utils.py
This commit is contained in:
parent
3d21d135c8
commit
2c7f23dc32
1 changed files with 26 additions and 0 deletions
26
tests/unit_tests/test_utils.py
Normal file
26
tests/unit_tests/test_utils.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import os
|
||||
import filecmp
|
||||
|
||||
from openmc import _utils
|
||||
import pytest
|
||||
|
||||
@pytest.fixture()
|
||||
def download_photos(run_in_tmpdir):
|
||||
"""use _utils download() function to download the same picture three times,
|
||||
twice to get unique names, & a third time to use the already downloaded
|
||||
block of code"""
|
||||
_utils.download("https://i.ibb.co/HhKFc8x/small.jpg")
|
||||
_utils.download("https://tinyurl.com/y4t38ugb")
|
||||
_utils.download("https://tinyurl.com/y4t38ugb", as_browser=True)
|
||||
|
||||
|
||||
def test_checksum_error(run_in_tmpdir):
|
||||
"""use download() in such a way that will test the checksum error line"""
|
||||
phrase = "MD5 checksum for y4t38ugb"
|
||||
with pytest.raises(OSError, match=phrase):
|
||||
_utils.download("https://tinyurl.com/y4t38ugb", as_browser=True,
|
||||
checksum="not none")
|
||||
|
||||
|
||||
def test_photos(download_photos):
|
||||
assert filecmp.cmp("small.jpg", "y4t38ugb")
|
||||
Loading…
Add table
Add a link
Reference in a new issue