tests: fix PytestCollectionWarning (#75521)
gitea/wcs/pipeline/head This commit looks good Details

This commit is contained in:
Benjamin Dauvergne 2023-03-16 14:31:45 +01:00
parent 37d76f5de5
commit 6c3cf18586
3 changed files with 12 additions and 5 deletions

View File

@ -438,13 +438,13 @@ def test_shell():
call_command('shell') # missing tenant name
class TestAfterJob(AfterJob):
class AfterJobForTest(AfterJob):
def execute(self):
self.test_result = WorkflowStatusItem().compute('{{ global_title|default:"FAIL" }}')
self.l10n_month = WorkflowStatusItem().compute('{{ "10/10/2010"|date:"F" }}')
class TestExceptionAfterJob(AfterJob):
class AfterJobForTestWithException(AfterJob):
def execute(self):
raise ZeroDivisionError()
@ -462,7 +462,7 @@ def test_runjob(pub):
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
pub.site_options.write(fd)
job = TestAfterJob(label='test')
job = AfterJobForTest(label='test')
job.store()
assert AfterJob.get(job.id).status == 'registered'
call_command('runjob', '--domain=example.net', '--job-id=%s' % job.id)
@ -472,7 +472,7 @@ def test_runjob(pub):
pub.cfg['language'] = {'language': 'fr'}
pub.write_cfg()
job = TestAfterJob(label='test2')
job = AfterJobForTest(label='test2')
job.store()
assert AfterJob.get(job.id).status == 'registered'
call_command('runjob', '--domain=example.net', '--job-id=%s' % job.id)
@ -489,7 +489,7 @@ def test_runjob(pub):
assert AfterJob.get(job.id).completion_time != completion_time
# test exception handling
job = TestExceptionAfterJob(label='test3')
job = AfterJobForTestWithException(label='test3')
job.store()
assert AfterJob.get(job.id).status == 'registered'
call_command('runjob', '--domain=example.net', '--job-id=%s' % job.id)

View File

@ -73,3 +73,7 @@ deps =
commands =
./getlasso3.sh
./pylint.sh wcs/ tests/
[pytest]
filterwarnings =
error::_pytest.warning_types.PytestCollectionWarning

View File

@ -36,6 +36,9 @@ class TestError(Exception):
self.msg = msg
self.error = error
# prevent pytest from trying to collect this class (#75521)
__test__ = False
class TestDef(sql.TestDef):
_names = 'testdef'