mirror of
https://github.com/p2p-ld/numpydantic.git
synced 2024-11-12 17:54:29 +00:00
fix test interfaces not being disabled
This commit is contained in:
parent
4152af1f91
commit
88fd42cdc3
2 changed files with 26 additions and 12 deletions
|
@ -1,5 +1,11 @@
|
|||
import pytest
|
||||
"""
|
||||
Tests for the interface base model,
|
||||
for tests that should apply to all interfaces, use ``test_interfaces.py``
|
||||
"""
|
||||
|
||||
import gc
|
||||
|
||||
import pytest
|
||||
import numpy as np
|
||||
|
||||
from numpydantic.interface import Interface
|
||||
|
@ -8,6 +14,7 @@ from numpydantic.interface import Interface
|
|||
@pytest.fixture(scope="module")
|
||||
def interfaces():
|
||||
"""Define test interfaces in this module, and delete afterwards"""
|
||||
interfaces_enabled = True
|
||||
|
||||
class Interface1(Interface):
|
||||
input_types = (list,)
|
||||
|
@ -24,7 +31,7 @@ def interfaces():
|
|||
|
||||
@classmethod
|
||||
def enabled(cls) -> bool:
|
||||
return True
|
||||
return interfaces_enabled
|
||||
|
||||
Interface2 = type("Interface2", Interface1.__bases__, dict(Interface1.__dict__))
|
||||
Interface2.checked = False
|
||||
|
@ -44,7 +51,7 @@ def interfaces():
|
|||
|
||||
@classmethod
|
||||
def enabled(cls) -> bool:
|
||||
return True
|
||||
return interfaces_enabled
|
||||
|
||||
class Interfaces:
|
||||
interface1 = Interface1
|
||||
|
@ -55,9 +62,13 @@ def interfaces():
|
|||
yield Interfaces
|
||||
# Interface.__subclasses__().remove(Interface1)
|
||||
# Interface.__subclasses__().remove(Interface2)
|
||||
del Interfaces
|
||||
del Interface1
|
||||
del Interface2
|
||||
del Interface3
|
||||
del Interface4
|
||||
interfaces_enabled = False
|
||||
gc.collect()
|
||||
|
||||
|
||||
def test_interface_match_error(interfaces):
|
||||
|
@ -151,12 +162,3 @@ def test_interface_recursive(interfaces):
|
|||
assert issubclass(interfaces.interface3, interfaces.interface1)
|
||||
assert issubclass(interfaces.interface1, Interface)
|
||||
assert interfaces.interface4 in ifaces
|
||||
|
||||
|
||||
def test_interface_revalidate(all_interfaces):
|
||||
"""
|
||||
An interface should revalidate with the output of its initial validation
|
||||
|
||||
See: https://github.com/p2p-ld/numpydantic/pull/14
|
||||
"""
|
||||
_ = type(all_interfaces)(array=all_interfaces.array)
|
12
tests/test_interface/test_interfaces.py
Normal file
12
tests/test_interface/test_interfaces.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
"""
|
||||
Tests that should be applied to all interfaces
|
||||
"""
|
||||
|
||||
|
||||
def test_interface_revalidate(all_interfaces):
|
||||
"""
|
||||
An interface should revalidate with the output of its initial validation
|
||||
|
||||
See: https://github.com/p2p-ld/numpydantic/pull/14
|
||||
"""
|
||||
_ = type(all_interfaces)(array=all_interfaces.array)
|
Loading…
Reference in a new issue