All of the unit tests are located within the directory tree starting at test/units. These tests should all be self-contained and do not require access to external resources. Running the tests is as simple as executing make tests from the root of the Ansible source checkout. This will test much of the code base, including the module code.
To target a specific set of tests to run, the pytest (sometimes accessed as py.test) utility can be called directly, with a path provided to a directory or a specific file to test. In this example, just the parsing unit tests are executed:
As can be seen in the screenshot, the py.test utility is running through the defined unit tests and will report any errors it finds, aiding you greatly in checking any code you might be planning to submit.