TabsManager.py Added unit tests + documentation
This commit is contained in:
@@ -74,8 +74,8 @@ def test_i_can_manage_notstr_success_path(ft, to_search, expected):
|
||||
(NotStr("hello my friend"), TestObject(NotStr, s="hello")),
|
||||
])
|
||||
def test_test_i_can_manage_notstr_failure_path(ft, to_search):
|
||||
with pytest.raises(AssertionError):
|
||||
find(ft, to_search)
|
||||
res = find(ft, to_search)
|
||||
assert res == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize('ft, expected', [
|
||||
@@ -85,5 +85,4 @@ def test_test_i_can_manage_notstr_failure_path(ft, to_search):
|
||||
(Div(id="id2"), Div(id="id1")),
|
||||
])
|
||||
def test_i_cannot_find(ft, expected):
|
||||
with pytest.raises(AssertionError):
|
||||
find(expected, ft)
|
||||
assert find(expected, ft) == []
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import pytest
|
||||
from fastcore.basics import NotStr
|
||||
from fasthtml.components import *
|
||||
|
||||
from myfasthtml.controls.helpers import mk
|
||||
from myfasthtml.core.commands import Command
|
||||
from myfasthtml.icons.fluent_p3 import add20_regular
|
||||
from myfasthtml.test.matcher import matches, StartsWith, Contains, DoesNotContain, Empty, ErrorOutput, \
|
||||
ErrorComparisonOutput, AttributeForbidden, AnyValue, NoChildren, TestObject, Skip, DoNotCheck, TestIcon, HasHtmx
|
||||
from myfasthtml.test.matcher import *
|
||||
from myfasthtml.test.testclient import MyFT
|
||||
|
||||
|
||||
@@ -468,3 +466,16 @@ class TestPredicates:
|
||||
c = Command("c", "testing has_htmx", None)
|
||||
c.bind_ft(div)
|
||||
assert HasHtmx(command=c).validate(div)
|
||||
|
||||
def test_i_can_use_and(self):
|
||||
contains1 = Contains("value1")
|
||||
contains2 = Contains("value2")
|
||||
not_contains1 = DoesNotContain("value1")
|
||||
not_contains2 = DoesNotContain("value2")
|
||||
|
||||
assert And(contains1, contains2).validate("value1 value2")
|
||||
assert And(contains1, not_contains2).validate("value1")
|
||||
assert And(not_contains1, contains2).validate("value2")
|
||||
assert And(not_contains1, not_contains2).validate("value3")
|
||||
|
||||
assert not And(contains1, not_contains2).validate("value2")
|
||||
|
||||
Reference in New Issue
Block a user