Testing#

Pytest is the official testing framework for MontePy. In the past it was unittest, and so the test suite is in a state of transition. Here are the principles for writing new tests:

  1. Do not write any new tests using unittest.TestCase.

  2. Use assert and not self.assert..., even if it’s available.

  3. parametrizing is preferred over verbose tests.

  4. Use fixtures.

  5. Use property based testing with hypothesis, when it makes sense. This is generally for complicated functions that users use frequently, such as constructors. See this tutorial for an introduction to property based testing.

Test Organization#

Tests are organized in the tests folder in the following way:

  1. Unit tests are in their own files for each class or a group of classes.

  2. Integration tests go in tests/test_*integration.py. New integration files are welcome.

  3. Interface tests with other libraries, e.g., pickle go in tests/test_interface.py.

  4. Test classes are preffered to organize tests by concepts. Each MontePy class should have its own test class. These should not subclass anything. Methods should accept _ instead of self to note that class structure is purely organizational.

Test Migration#

Currently the test suite does not conform to these standards fully. Help with making the migration to the new standards is appreciated. So don’t think something is sacred about a test file that does not follow these conventions.