pyqtgraph/tests/parametertree/test_Parameter.py
Ogi Moore a6971c768d Move and Update test-data repo into pyqtgraph repo
To reduce complexity, and make it easier to add more images and tests,
the images in the `test-data` repository should be merged with the main
repository.  Furthermore, we can remove a lot of the subprocess work in
the image_testing.py file, as we no longer need to have it interact with
git.

The images are not the same.  Images were regenerated with Qt6, and now
have proper big and little endian handling thanks to @pijyoi

Second commit is a slightly modified variant of
2e135ab282d6007b34a3854921be54d0e9efb241 authored by @pijyoi
it is to convert qimages to RGBA8888 for testing.  Image
files were regenerated images for the big/little handling

Fixed issue with bogus test from test_NonUniformImage and generated a
new image
2021-05-31 21:05:00 -07:00

45 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
import pytest
from pyqtgraph.parametertree import Parameter
def test_parameter_hasdefault():
opts = {'name': 'param', 'type': int, 'value': 1}
# default unspecified
p = Parameter(**opts)
assert p.hasDefault()
assert p.defaultValue() == opts["value"]
p.setDefault(2)
assert p.hasDefault()
assert p.defaultValue() == 2
# default specified
p = Parameter(default=0, **opts)
assert p.hasDefault()
assert p.defaultValue() == 0
# default specified as None
p = Parameter(default=None, **opts)
assert not p.hasDefault()
def test_unpack_parameter():
# test that **unpacking correctly returns child name/value maps
params = [
dict(name='a', type='int', value=1),
dict(name='b', type='str', value='2'),
dict(name='c', type='float', value=3.0),
]
p = Parameter.create(name='params', type='group', children=params)
result = dict(**p)
assert 'a' in result
assert result['a'] == 1
assert 'b' in result
assert result['b'] == '2'
assert 'c' in result
assert result['c'] == 3.0