Skip to content

Commit

Permalink
test(hash): add __hash__ test to avoid pydantic 1.8 bug in future
Browse files Browse the repository at this point in the history
fix #280
  • Loading branch information
AntoineDao committed Mar 3, 2021
1 parent f54482f commit 2c5f70a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/base/hash_test.py
@@ -0,0 +1,18 @@
import pytest

from ._base import BaseTestClass

@pytest.mark.hash
class BaseHashTest(BaseTestClass):

def pytest_generate_tests(self, metafunc):

object_instances = self.fixture_instances('valid')

if "instance" in metafunc.fixturenames:
metafunc.parametrize("instance", object_instances)

def test_generates_hash(self, instance):
"""Test to check for bug introduced in Pydantic 1.8"""

assert instance.__hash__ is not None
8 changes: 8 additions & 0 deletions tests/operator/operator_test.py
Expand Up @@ -2,6 +2,7 @@
from tests.base.io_test import BaseIOTest
from tests.base.value_error import BaseValueErrorTest
from tests.base.folder_test import BaseFolderTest
from tests.base.hash_test import BaseHashTest

from queenbee.plugin import Plugin

Expand All @@ -27,3 +28,10 @@ class TestFolder(BaseFolderTest):
klass = Plugin

asset_folder = ASSET_FOLDER


class TestHash(BaseHashTest):

klass = Plugin

asset_folder = ASSET_FOLDER
8 changes: 8 additions & 0 deletions tests/recipe/recipe_test.py
@@ -1,6 +1,7 @@
from tests.base.io_test import BaseIOTest
from tests.base.value_error import BaseValueErrorTest
from tests.base.folder_test import BaseFolderTest
from tests.base.hash_test import BaseHashTest

from queenbee.recipe import Recipe

Expand All @@ -26,3 +27,10 @@ class TestFolder(BaseFolderTest):
klass = Recipe

asset_folder = ASSET_FOLDER


class TestHash(BaseHashTest):

klass = Recipe

asset_folder = ASSET_FOLDER

0 comments on commit 2c5f70a

Please sign in to comment.