Commit 0ed81846 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'rel/1.7' into 'master'

Rel/1.7

See merge request fsl/fsleyes/props!38
parents 70e8f1a9 0f5fa36c
......@@ -2,6 +2,11 @@
source /test.venv/bin/activate
apt install -y locales
locale-gen en_US.UTF-8
locale-gen en_GB.UTF-8
update-locale
# If running on a fork repository, we merge in the
# upstream/master branch. This is done so that merge
# requests from fork to the parent repository will
......
......@@ -2,6 +2,17 @@ This document contains the ``fsleyes-props`` release history in reverse
chronological order.
1.7.0 (Tuesday May 26th 2020)
-----------------------------
Added
^^^^^
* Added a short-hand alias for :class:`.HasProperties` - ``HasProps``.
1.6.7 (Friday October 4th 2019)
-------------------------------
......
Copyright 2016-2018 University of Oxford, Oxford, UK
Copyright 2016-2020 University of Oxford, Oxford, UK
The fsleyes-props library
Copyright 2016-2018 University of Oxford, Oxford, UK.
Copyright 2016-2020 University of Oxford, Oxford, UK.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......
......@@ -291,7 +291,7 @@ notification of properties to be suppressed in a ``with`` statement.
"""
__version__ = '1.7.0.dev0'
__version__ = '1.8.0.dev0'
import sys
......@@ -304,6 +304,7 @@ log = logging.getLogger(__name__)
from .properties import (
PropertyOwner,
HasProperties,
HasProps,
DisabledError)
from .properties_value import (
......
......@@ -532,6 +532,9 @@ class HasProperties(object):
"""Base class for classes which contain ``PropertyBase`` instances. All
classes which contain ``PropertyBase`` objects must subclass this
class.
.. note:: ``HasProperties`` is also available via an alias called
:attr:`HasProps`.
"""
......@@ -1051,3 +1054,7 @@ class HasProperties(object):
lines.append(fmtStr.format(propName, propVal))
return '\n'.join(lines)
HasProps = HasProperties
"""``HasProps`` is simply an alias for :class:`HasProperties`. """
sphinx
sphinx_rtd_theme
mock
coverage
pytest
pytest-cov
......@@ -24,8 +24,7 @@ basedir = op.dirname(__file__)
with open(op.join(basedir, 'requirements.txt'), 'rt') as f:
install_requires = [l.strip() for l in f.readlines()]
packages = find_packages(
exclude=('doc', 'tests', 'dist', 'build', 'fsleyes_props.egg-info'))
packages = find_packages(include=('fsleyes_props', 'fsleyes_props.*'))
# Extract the vesrion number from fsleyes_props/__init__.py
version = {}
......
......@@ -112,6 +112,27 @@ def simclick(sim, target, btn=wx.MOUSE_BTN_LEFT, pos=None, stype=0):
realYield()
class MockMouseEvent:
def __init__(self, target, pos=None):
w, h = target.GetClientSize().Get()
if pos is None:
pos = [0.5, 0.5]
self.x = w * pos[0]
self.y = h * pos[1]
def GetX(self):
return self.x
def GetY(self):
return self.y
def simtext(sim, target, text, enter=True):
target.SetFocus()
......
......@@ -12,7 +12,7 @@ import fsleyes_props as props
import fsleyes_widgets.bitmaptoggle as bmptoggle
import fsleyes_widgets.bitmapradio as bmpradio
from . import run_with_wx, simclick, addall, realYield
from . import run_with_wx, addall, realYield
datadir = op.join(op.dirname(__file__), 'testdata')
......@@ -32,7 +32,6 @@ def _test_widget_boolean(parent):
trueicon = op.join(datadir, 'true.png')
falseicon = op.join(datadir, 'false.png')
sim = wx.UIActionSimulator()
obj = MyObj()
# ch
......
......@@ -8,7 +8,7 @@
import wx
import numpy as np
from . import (run_with_wx, simtext, simclick, addall)
from . import (run_with_wx, addall, MockMouseEvent, realYield)
import fsleyes_props as props
import fsleyes_widgets.floatspin as floatspin
......@@ -31,8 +31,6 @@ class MyObj(props.HasProperties):
def test_widget_number(): run_with_wx(_test_widget_number)
def _test_widget_number(parent):
sim = wx.UIActionSimulator()
obj = MyObj()
myinto = props.makeWidget(parent, obj, 'myinto')
......@@ -57,10 +55,21 @@ def _test_widget_number(parent):
assert myintc .GetValue() == 25
assert np.isclose(myrealc.GetValue(), 0.5)
simtext( sim, myinto .textCtrl, '10')
simtext( sim, myrealo.textCtrl, '243.56')
simtext( sim, myintc.spinCtrl.textCtrl, '99')
simclick(sim, myrealc, pos=(0.75, 0.5))
# I used to use wx.UIActionSimulator, but
# it is too flaky. So am now simulating
# user events by directly calling value
# setters/event handlers
myinto .textCtrl.SetValue('10')
myinto._FloatSpinCtrl__onText(None)
myrealo .textCtrl.SetValue('243.56')
myrealo._FloatSpinCtrl__onText(None)
myintc .spinCtrl.textCtrl.SetValue('99')
myintc .spinCtrl._FloatSpinCtrl__onText(None)
ev = MockMouseEvent(myrealc, (0.75, 0.5))
myrealc._FloatSlider__onMouseDown(ev)
myrealc._FloatSlider__onMouseUp( ev)
realYield()
assert obj.myinto == 10
assert np.isclose(obj.myrealo, 243.56)
......
......@@ -12,7 +12,7 @@ import fsleyes_props as props
import fsleyes_widgets.floatslider as floatslider
from . import (run_with_wx, simtext, simclick, addall, realYield)
from . import (run_with_wx, MockMouseEvent, addall, realYield)
def setup_module():
......@@ -72,6 +72,9 @@ def _test_widget_point(parent):
val = np.random.randint(0, 100)
simclick(sim, widget.slider, pos=(val / 100.0, 0.5))
ev = MockMouseEvent(widget.slider, (val / 100.0, 0.5))
widget.slider._FloatSlider__onMouseDown(ev)
widget.slider._FloatSlider__onMouseUp(ev)
realYield()
assert abs(getattr(getattr(obj, prop), att) - val) < 10
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment