mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-18 02:36:31 +00:00
Unit test fixes (#10019)
* Add --keepdb option for unit test * Reduce server launch overhead - isGeneratingSchema was EXPENSIVE - Running a single unit test reduced from 30s to 3s * Option to disable check
This commit is contained in:
20
tasks.py
20
tasks.py
@@ -1212,33 +1212,29 @@ def test_translations(c):
|
||||
|
||||
@task(
|
||||
help={
|
||||
'check': 'Run sanity check on the django install (default = False)',
|
||||
'disable_pty': 'Disable PTY',
|
||||
'runtest': 'Specify which tests to run, in format <module>.<file>.<class>.<method>',
|
||||
'migrations': 'Run migration unit tests',
|
||||
'report': 'Display a report of slow tests',
|
||||
'coverage': 'Run code coverage analysis (requires coverage package)',
|
||||
'translations': 'Compile translations before running tests',
|
||||
'keepdb': 'Keep the test database after running tests (default = False)',
|
||||
}
|
||||
)
|
||||
def test(
|
||||
c,
|
||||
check=False,
|
||||
disable_pty=False,
|
||||
runtest='',
|
||||
migrations=False,
|
||||
report=False,
|
||||
coverage=False,
|
||||
translations=False,
|
||||
keepdb=False,
|
||||
):
|
||||
"""Run unit-tests for InvenTree codebase.
|
||||
|
||||
Args:
|
||||
c: Command line context.
|
||||
disable_pty (bool): Disable PTY (default = False)
|
||||
runtest (str): Specify which tests to run, in format <module>.<file>.<class>.<method> (default = '')
|
||||
migrations (bool): Run migration unit tests (default = False)
|
||||
report (bool): Display a report of slow tests (default = False)
|
||||
coverage (bool): Run code coverage analysis (requires coverage package) (default = False)
|
||||
translations (bool): Compile translations before running tests (default = False)
|
||||
|
||||
To run only certain test, use the argument --runtest.
|
||||
This can filter all the way down to:
|
||||
<module>.<file>.<class>.<method>
|
||||
@@ -1248,7 +1244,8 @@ def test(
|
||||
will run tests in the company/test_api.py file.
|
||||
"""
|
||||
# Run sanity check on the django install
|
||||
manage(c, 'check')
|
||||
if check:
|
||||
manage(c, 'check')
|
||||
|
||||
if translations:
|
||||
try:
|
||||
@@ -1272,6 +1269,9 @@ def test(
|
||||
if report:
|
||||
cmd += ' --slowreport'
|
||||
|
||||
if keepdb:
|
||||
cmd += ' --keepdb'
|
||||
|
||||
if migrations:
|
||||
cmd += ' --tag migration_test'
|
||||
else:
|
||||
|
Reference in New Issue
Block a user