Giter Site home page Giter Site logo

comptests's Introduction

CircleCI

comptests

Testing utilities built on top of [ConfTools][conftools], [CompMake][compmake] and [QuickApp][quickapp].

Basic Usage

This is the usage for packages that register objects using [ConfTools][conftools].

Defining tests

Call the function comptests_for_all to create a decorator:

# get the library (ObjSpec)
library_robots = get_conftools_robots()

# Create a test decorator
for_all_robots = comptests_for_all(library_robots)

# Use the decorator to specify tests. Test functions
# must take two arguments: id object and object itself

@for_all_robots
def check_robot_type(id_robot, robot):
    assert isinstance(robot, RobotInterface)

You can also register tests for pairs:

library_nuisances = get_conftools_nuisances()
for_all_robot_nuisance_pairs = comptests_for_all_pairs(library_robots, library_nuisances)

@for_all_robot_nuisance_pairs
def check_nuisances_obs(id_robot, robot, id_nuisance, nuisance):
    check_conversions(robot.get_spec().get_observations(), nuisance)

Running tests

Use the command line:

comptests <module>

This looks for the get_comptests() function in <module>:

def get_comptests():
    get_comptests():
    # get testing configuration directory
    from pkg_resources import resource_filename
    dirname = resource_filename("boot_agents", "configs")
    # load unittests
    from . import unittests
    from comptests import get_comptests_app
    # Get the Quickapp for the boot_config
    app = get_comptests_app(get_boot_config())
    return [app]

Finding coverage information

It's very usuful to use the coverage tool together with comptests.

Install the coverage tool:

pip install coverage

If coverage is installed then comptests automatically computes the coverage information for nosetests execution.

To do the coverage information for the comptests, run like this:

coverage run =comptests -c "make recurse=1" <package>

Note that you cannot use parallel testing (using parmake) otherwise coverage gets confused.

This displays the results:

coverage report -m

Then create the HTML report:

coverage html -d outdir

comptests's People

Contributors

andreacensi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.