Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Quality Assurance and Testing

    pytest-quickcheck 0.7

    Download button

    No screenshots available
    Downloads: 156  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Tetsuya Morimoto | More programs
    The Apache License 2.0 / FREE
    April 1st, 2012, 15:33 GMT [view history]
    ROOT / Programming / Quality Assurance and Testing

     Read user reviews (0)  Refer to a friend  Subscribe

    pytest-quickcheck description

    pytest plugin to generate random data inspired by QuickCheck

    pytest-quickcheck provides a pytest.mark.randomize function for generating random test data.

    Installation

     easy_install pytest-quickcheck # or
     pip install pytest-quickcheck


    Quick Start

    Just pass the signature of function to randomize marker. The signature is represented a tuple consist of argument name and its type.

    @pytest.mark.randomize(("i1", "int"), ("i2", "int"), ncalls=1)
    def test_generate_ints(i1, i2):
     pass


    More complex data structure:

    @pytest.mark.randomize(
     ("d1", "{'x': int, 'y': [str, (int, int)], 'z': {'x': str}}")
    )
    def test_generate_dict(d1):
     pass


    The randomize marker is able to use with parametrize marker.

    @pytest.mark.parametrize("prime", [2, 3, 5])
    @pytest.mark.randomize(("i1", "int"), ("f1", "float"), ncalls=1)
    def test_gen_parametrize_with_randomize_int_float(prime, i1, f1):
     pass


    Using command line option --randomize restricts only the randomize test.

    $ py.test -v --randomize test_option.py
    ==========================================================================================
    test session starts
    ==========================================================================================
    test_option.py:5: test_normal SKIPPED
    test_option.py:8: test_generate_ints[74-22] PASSED


    Usage

    There some options for each data type:

    $ py.test --markers
    @pytest.mark.randomize((argname, type), **options): mark the test function with
    random data generating any data type.
     There are options for each data type: (see doc for details)
     int: ['min_num', 'max_num']
     float: ['min_num', 'max_num', 'positive']
     str: ['encoding', 'fixed_length', 'max_length', 'str_attrs']


    - common option

     ncalls: set the number of calls. Defaults to 3. (e.g. ncalls=5)
     choices: choose from given sequence. (e.g. choices=[3, 5, 7])

    - int

     min_num: lower limit for generating integer number. (e.g. min_num=0)
     max_num: upper limit for generating integer number. (e.g. max_num=10)

    - float

     min_num: lower limit for generating real number. (e.g. min_num=0.0)
     max_num: upper limit for generating real number. (e.g. max_num=1.0)
     positive: generate only positive real number if set to True. Defaults to False. (e.g. positive=True)

    - str

     encoding: generate unicode string encoded given character code. (e.g. encoding="utf-8") # for Python 2.x only
     fixed_length: generate fixed length string. (e.g. fixed_length=8)
     max_length: generate the string less than or equal to max length (e.g. max_length=32)
     str_attrs: generate the string in given letters. set a tuple consist of attribute names in the string module. (e.g. str_attrs=("digits", "punctuation")

    Probably, pytest_quickcheck/tests/test_plugin_basic.py is useful for learning how to use these options.


    Product's homepage

    Requirements:

    · Python
    · py.test

    What's New in This Release: [ read full changelog ]

    · The types in the arguments are specified by the types themselves (#1)

      


    TAGS:

    py.test plugin | generate random data | py.test | random | data

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM