Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
731b9f60
Commit
731b9f60
authored
9 years ago
by
Christophe Simonis
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] account: skip tests using `skipTest` method
parent
6016b16a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
addons/account/tests/account_test_classes.py
+7
-33
7 additions, 33 deletions
addons/account/tests/account_test_classes.py
with
7 additions
and
33 deletions
addons/account/tests/account_test_classes.py
+
7
−
33
View file @
731b9f60
import
logging
# -*- coding: utf-8 -*-
from
openerp.tests.common
import
TransactionCase
from
openerp
import
SUPERUSER_ID
from
openerp
import
api
from
openerp.modules.registry
import
RegistryManager
from
openerp.tools
import
config
DB
=
config
[
'
db_name
'
]
_logger
=
logging
.
getLogger
(
__name__
)
class
AccountingTestCase
(
TransactionCase
):
"""
This class extends the base TransactionCase, in order to test the
accounting with localization setups. It is configured to run the tests after
the installation of all modules, and will SKIP TESTS and return a success if
it cannot find an already configured accounting (which means no localization
module has been installed).
the installation of all modules, and will SKIP TESTS ifit cannot find an already
configured accounting (which means no localization module has been installed).
"""
post_install
=
True
at_install
=
False
def
_check_accounting_configured
(
self
):
# minimal setUp() similar to the one of TransactionCase, although we
# can't use the regular setUp() because we want to assume the accounting
# is already configured when making the setUp of tests.
self
.
registry
=
RegistryManager
.
get
(
DB
)
self
.
cr
=
self
.
cursor
()
self
.
uid
=
SUPERUSER_ID
self
.
env
=
api
.
Environment
(
self
.
cr
,
self
.
uid
,
{})
# having at least one account created means the accounting is ready to be tested
def
setUp
(
self
):
super
(
AccountingTestCase
,
self
).
setUp
()
domain
=
[(
'
company_id
'
,
'
=
'
,
self
.
env
.
ref
(
'
base.main_company
'
).
id
)]
res
=
bool
(
self
.
env
[
'
account.account
'
].
search_count
(
domain
))
# rollback and close the cursor, and reset the environment
self
.
tearDown
()
return
res
def
run
(
self
,
result
=
None
):
if
not
self
.
_check_accounting_configured
():
# no chart of account is available, so skip the tests and consider
# it as a success
_logger
.
warning
(
"
No chart of account, skip %s
"
,
self
)
return
super
(
AccountingTestCase
,
self
).
run
(
result
=
result
)
if
not
self
.
env
[
'
account.account
'
].
search_count
(
domain
):
self
.
skipTest
(
"
No Chart of account found
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment