pytest
to run tests, Masonite's test suite is based on unittest
. So you will use unittest
syntax 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.testing
. You are free to define other testing environment configuration values as necessary..env.testing
file. Feel free to load any testing environment variables in here. By default they will not be commited. When pytest
runs it will additionally load and override any additional environment variables.test_
and then creating a test class inheriting from masonite TestCase
class.tests/unit/test_some_feature.py
:assert
can 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.assertRaises()
context manager:captureOutput()
context manager:debugMode()
context manager: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.now
(or today
, tomorrow
yesterday
) instance is created. It's really useful during tests to check timestamps logic.pendulum
behaviour with restoreTime()
helper to avoid breaking other tests. It can be done directly in the test or in a tearDown()
method.self.fakeTime(pendulum.tomorrow())
).seconds
, minutes
, hours
, days
(default), weeks
, months
, years
.seconds
, minutes
, hours
, days
(default), weeks
, months
, years
.pendulum
. When using fake
time helpers you should not forget to call this helper at the end.tearDown()
method.