Skip to main content

dbus signature hypothesis strategy generator

Project description

This package contains a Hypothesis strategy for generating DBus signatures. An informal specification of DBus signatures is available at: https://dbus.freedesktop.org/doc/dbus-specification.html.

The strategy is intended to be both sound and complete. That is, it should never generate an invalid DBus signature and it should be capable, modulo size constraints, of generating any valid DBus signature.

Usage

Import the function and obtain a strategy with the default parameters.

>>> from hs_dbus_signature import dbus_signatures
>>> strategy = dbus_signatures()

Obtain a few examples of valid signatures, e.g.,

>>> strategy.example()
''
>>> strategy.example()
'a{ng}'
>>> strategy.example()
'a{xas}a{gah}a{nau}'

Make use of the strategy in your tests, e.g.

from hypothesis import given

@given(dbus_signatures())
def test(signature):
    ...

Use the parameters to omit dicts

>>> strategy = dbus_signatures(exclude_dicts=True)
>>> strategy.example()
'(gnggg)(n)(gn)(nnnnn)(nn)'

or to ensure that no example signature is the empty string

>>> strategy = dbus_signatures(min_complete_types=1)
>>> strategy.example()
'a{sv}'

The strategy will raise an InvalidArgument exception immediately if it is given arguments which allow no examples to be drawn.

>>> strategy = dbus_signatures(blacklist=string.ascii_lowercase)
Traceback (most recent call last):
...

Remarks

Documentation for the Hypothesis testing library can be found at http://hypothesis.readthedocs.io.

This strategy makes use of the Hypothesis higher-order strategy, recursive(), which is discussed here: http://hypothesis.works/articles/recursive-data/.

It is only supported for Python 3 as it uses Python 3 only syntax.

Downstream packagers, if incorporating testing into their packaging, are encouraged to use only the tests in the test_deterministic.py module, to avoid testing failures that may arise due to the non-deterministic behavior of Hypothesis tests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hs-dbus-signature-0.7.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hs_dbus_signature-0.7-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file hs-dbus-signature-0.7.tar.gz.

File metadata

  • Download URL: hs-dbus-signature-0.7.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.2 pkginfo/1.4.2 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.9

File hashes

Hashes for hs-dbus-signature-0.7.tar.gz
Algorithm Hash digest
SHA256 34d9d37125fe2bccd4fac8f5401775de1eda11737d56a96d24c3560ae86067a2
MD5 32d009502f1eefc9701791676e6cdaaa
BLAKE2b-256 11ee72d996c8902d3b631b79fa9f3a2e6edd8956505f13dee4ef1fe07b64ba03

See more details on using hashes here.

File details

Details for the file hs_dbus_signature-0.7-py3-none-any.whl.

File metadata

  • Download URL: hs_dbus_signature-0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.2 pkginfo/1.4.2 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.9

File hashes

Hashes for hs_dbus_signature-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6fcd70449896d043dfa6e1a7047b9a1ead40adfdd2156c30ed47b8542828f83f
MD5 e4a638d89444452d245f91628cf14c5b
BLAKE2b-256 801c10c0294c96a36c43d2783b33a0873d8217b5944f8bea6e46807d8e860bf2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page