зеркало из
https://github.com/ssciwr/AMMICO.git
synced 2025-10-29 13:06:04 +02:00
* Create ci.yml * include pytest * Update pyproject.toml * include pytest-cov * use approx in pytest * Update test_faces.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add coverage yaml * reduce passing grade Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
27 строки
771 B
Python
27 строки
771 B
Python
import misinformation.faces as fc
|
|
import json
|
|
from pytest import approx
|
|
|
|
|
|
def test_analyse_faces():
|
|
mydict = {
|
|
"filename": "./test/data/IMG_2746.png",
|
|
}
|
|
mydict = fc.EmotionDetector(mydict).analyse_image()
|
|
print(mydict)
|
|
|
|
with open("./test/data/example_faces.json", "r") as file:
|
|
out_dict = json.load(file)
|
|
|
|
for key in mydict.keys():
|
|
if key != "emotion":
|
|
assert mydict[key] == out_dict[key]
|
|
# json can't handle tuples natively
|
|
for i in range(0, len(mydict["emotion"])):
|
|
temp = (
|
|
list(mydict["emotion"][i])
|
|
if type(mydict["emotion"][i]) == tuple
|
|
else mydict["emotion"][i]
|
|
)
|
|
assert approx(temp) == out_dict["emotion"][i]
|