Tests that come with pyfrc

pyfrc comes with testing functions that can be used to test basic functionality of just about any robot, including running through a simulated practice match.

These generic test modules can be applied to wpilib.IterativeRobot and wpilib.SampleRobot based robots.

The primary purpose of these tests is to run through your code and make sure that it doesn’t crash. If you actually want to test your code, you need to write your own custom tests to tease out the edge cases.

To use these, add the following to a python file in your tests directory:

from pyfrc.tests import *
pyfrc.tests.basic.test_autonomous(control, fake_time, robot)[source]

Runs autonomous mode by itself

pyfrc.tests.basic.test_disabled(control, fake_time, robot)[source]

Runs disabled mode by itself

pyfrc.tests.basic.test_operator_control(control, fake_time, robot)[source]

Runs operator control mode by itself

pyfrc.tests.basic.test_practice(control, fake_time, robot)[source]

Runs through the entire span of a practice match

Fuzz tests

The purpose of the fuzz ‘test’ is not exactly to ‘do’ anything, but rather it mashes the buttons and switches in various completely random ways to try and find any possible control situations and such that would probably never normally come up, but.. well, given a bit of bad luck, could totally happen.

Keep in mind that the results will totally different every time you run this, so if you find an error, fix it – but don’t expect that you’ll be able to duplicate it with this test. Instead, you should design a specific test that can trigger the bug, to ensure that you actually fixed it.

pyfrc.tests.fuzz_test.test_fuzz(hal_data, control, fake_time, robot)[source]

Runs through a whole game randomly setting components

Docstring tests

pyfrc.tests.docstring_test.ignore_object(o, robot_path)[source]

Returns true if the object can be ignored

pyfrc.tests.docstring_test.test_docstrings(robot, robot_path)[source]

The purpose of this test is to ensure that all of your robot code has docstrings. Properly using docstrings will make your code more maintainable and look more professional.