Skip to content

Commit

Permalink
Reorganized tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRaybaut committed Oct 23, 2023
1 parent 33f1e90 commit 7942e75
Show file tree
Hide file tree
Showing 35 changed files with 819 additions and 865 deletions.
52 changes: 0 additions & 52 deletions guidata/tests/_all_tests.py

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
# -*- coding: utf-8 -*-
#
# Licensed under the terms of the BSD 3-Clause
# (see guidata/LICENSE for details)

"""
ActivableDataSet example
Warning: ActivableDataSet objects were made to be integrated inside GUI layouts.
So this example with dialog boxes may be confusing.
--> see tests/editgroupbox.py to understand the activable dataset usage
"""

# When editing, all items are shown.
# When showing dataset in read-only mode (e.g. inside another layout), all items
# are shown except the enable item.

import guidata.dataset as gds
from guidata.env import execenv
from guidata.qthelpers import qt_app_context

# guitest: show


class Parameters(gds.ActivableDataSet):
"""
Example
<b>Activable dataset example</b>
"""

def __init__(self, title=None, comment=None, icon=""):
gds.ActivableDataSet.__init__(self, title, comment, icon)

enable = gds.BoolItem(
"Enable parameter set",
help="If disabled, the following parameters will be ignored",
default=False,
)
param0 = gds.ChoiceItem("Param 0", ["choice #1", "choice #2", "choice #3"])
param1 = gds.FloatItem("Param 1", default=0, min=0)
param2 = gds.FloatItem("Param 2", default=0.93)
color = gds.ColorItem("Color", default="red")


Parameters.active_setup()


def test_activable_dataset():
"""Test activable dataset"""
with qt_app_context():
prm = Parameters()
prm.set_writeable()
prm.edit()
prm.set_readonly()
prm.view()
execenv.print("OK")


if __name__ == "__main__":
test_activable_dataset()
# -*- coding: utf-8 -*-
#
# Licensed under the terms of the BSD 3-Clause
# (see guidata/LICENSE for details)

"""
ActivableDataSet example
Warning: ActivableDataSet objects were made to be integrated inside GUI layouts.
So this example with dialog boxes may be confusing.
--> see tests/editgroupbox.py to understand the activable dataset usage
"""

# When editing, all items are shown.
# When showing dataset in read-only mode (e.g. inside another layout), all items
# are shown except the enable item.

import guidata.dataset as gds
from guidata.env import execenv
from guidata.qthelpers import qt_app_context

# guitest: show


class Parameters(gds.ActivableDataSet):
"""
Example
<b>Activable dataset example</b>
"""

def __init__(self, title=None, comment=None, icon=""):
gds.ActivableDataSet.__init__(self, title, comment, icon)

enable = gds.BoolItem(
"Enable parameter set",
help="If disabled, the following parameters will be ignored",
default=False,
)
param0 = gds.ChoiceItem("Param 0", ["choice #1", "choice #2", "choice #3"])
param1 = gds.FloatItem("Param 1", default=0, min=0)
param2 = gds.FloatItem("Param 2", default=0.93)
color = gds.ColorItem("Color", default="red")


Parameters.active_setup()


def test_activable_dataset():
"""Test activable dataset"""
with qt_app_context():
prm = Parameters()
prm.set_writeable()
prm.edit()
prm.set_readonly()
prm.view()
execenv.print("OK")


if __name__ == "__main__":
test_activable_dataset()
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
# -*- coding: utf-8 -*-
#
# Licensed under the terms of the BSD 3-Clause
# (see guidata/LICENSE for details)

"""
Example with activable items: items which active state is changed depending
on another item's value.
"""

# guitest: show

from guidata.dataset import ChoiceItem, DataSet, FloatItem, FuncProp, GetAttrProp
from guidata.env import execenv
from guidata.qthelpers import qt_app_context

choices = (("A", "Choice #1: A"), ("B", "Choice #2: B"), ("C", "Choice #3: C"))


class Parameters(DataSet):
"""Example dataset"""

_prop = GetAttrProp("choice")
choice = ChoiceItem("Choice", choices).set_prop("display", store=_prop)
x1 = FloatItem("x1")
x2 = FloatItem("x2").set_prop("display", active=FuncProp(_prop, lambda x: x == "B"))
x3 = FloatItem("x3").set_prop("display", active=FuncProp(_prop, lambda x: x == "C"))


def test_activable_items():
"""Test activable items"""
with qt_app_context():
test = Parameters()
test.edit()
execenv.print("OK")


if __name__ == "__main__":
test_activable_items()
# -*- coding: utf-8 -*-
#
# Licensed under the terms of the BSD 3-Clause
# (see guidata/LICENSE for details)

"""
Example with activable items: items which active state is changed depending
on another item's value.
"""

# guitest: show

from guidata.dataset import ChoiceItem, DataSet, FloatItem, FuncProp, GetAttrProp
from guidata.env import execenv
from guidata.qthelpers import qt_app_context

choices = (("A", "Choice #1: A"), ("B", "Choice #2: B"), ("C", "Choice #3: C"))


class Parameters(DataSet):
"""Example dataset"""

_prop = GetAttrProp("choice")
choice = ChoiceItem("Choice", choices).set_prop("display", store=_prop)
x1 = FloatItem("x1")
x2 = FloatItem("x2").set_prop("display", active=FuncProp(_prop, lambda x: x == "B"))
x3 = FloatItem("x3").set_prop("display", active=FuncProp(_prop, lambda x: x == "C"))


def test_activable_items():
"""Test activable items"""
with qt_app_context():
test = Parameters()
test.edit()
execenv.print("OK")


if __name__ == "__main__":
test_activable_items()
Loading

0 comments on commit 7942e75

Please sign in to comment.