pytestto run tests, Masonite's test suite is based on
unittest. So you will use
unittestsyntax but run the tests with
pytest. Because of this, all syntax will be in camelCase instead of PEP 8 lower_case_with_underscores. Just know that all TestCase assertions used during testing is in camelCase form to maintain unittest standards.
.env.testingfile. Feel free to load any testing environment variables in here. By default they will not be commited. When
pytestruns it will additionally load and override any additional environment variables.
test_and then creating a test class inheriting from masonite
assertcan be chained together to run through many assertions. All other method will return some kind of boolean or value which you can use to do your own assertions.
print()statements will not be visible. You can use the
dump()test helper to dump data to console during a test:
stop()helper. You can even provide a reason.
yesterday) instance is created. It's really useful during tests to check timestamps logic.
pendulum. When using
faketime helpers you should not forget to call this helper at the end.