Skip to content

Commit

Permalink
Remove warning of pytest for rewriting modules
Browse files Browse the repository at this point in the history
Cause we are loading config and defaults from our run_ocsci.py wrapper
we need to add PYTEST_DONT_REWRITE msg to dosctring of modules where we
don't want to see warning.

Documentation:
https://docs.pytest.org/en/latest/reference.html#pytest-dont-rewrite-module-docstring

Reference where I found about this workarround is mentioned here:
pytest-dev/pytest-cov#148 (comment)
  • Loading branch information
petr-balogh authored and PrasadDesala committed Jun 7, 2019
1 parent 1f6ac6c commit 6d74951
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 25 deletions.
8 changes: 8 additions & 0 deletions ocs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
Avoid already-imported warning cause of we are importing this package from
run wrapper for loading config.
You can see documentation here:
https://docs.pytest.org/en/latest/reference.html
under section PYTEST_DONT_REWRITE
"""
37 changes: 20 additions & 17 deletions ocs/defaults.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
"""
Defaults module
Defaults module.
This module is automatically loaded with variables defined in
conf/ocsci/default_config.yaml in its DEFAULTS section.
If the variable can be used in some config file sections from ocsci/config.py
module, plese put your defaults rather to mentioned default_config.yaml file!
See the documentation in conf/README.md file to understand this config file.
PYTEST_DONT_REWRITE - avoid pytest to rewrite, keep this msg here please!
"""
import os
from getpass import getuser

THIS_DIR = os.path.dirname(os.path.abspath(__file__))
TOP_DIR = os.path.dirname(THIS_DIR)
TEMPLATE_DIR = os.path.join(TOP_DIR, "templates/ocs-deployment/")
STORAGE_API_VERSION = 'storage.k8s.io/v1'
ROOK_API_VERSION = 'ceph.rook.io/v1'
OCP_API_VERSION = 'project.openshift.io/v1'
OPENSHIFT_REST_CLIENT_API_VERSION = 'v1'

# This module is automatically loaded with variables defined in
# conf/ocsci/default_config.yaml in its DEFAULTS section.
# If the variable can be used in some config file sections from ocsci/config.py
# module, plese put your defaults rather to mentioned default_config.yaml file!

# See the documentation in conf/README.md file to understand this config file.

# Those variables are duplicate at the moment from default_config.yaml and once
# we drop support for old runner we will remove those variables from here and
# will have them defined only on one place.
# Those variables below are duplicate at the moment from default_config.yaml
# and once we drop support for old runner we will remove those variables from
# here and will have them defined only on one place.

# Be aware that variables defined below are not used anywhere in th config
# files and their sections when we rendering config!
# Be aware that variables defined above and below are not used anywhere in the
# config files and their sections when we rendering config!

INSTALLER_VERSION = '4.1.0-rc.3'
CLIENT_VERSION = INSTALLER_VERSION
Expand All @@ -44,7 +51,3 @@
'ceph_image': CEPH_IMAGE,
'rook_image': ROOK_IMAGE,
}
STORAGE_API_VERSION = 'storage.k8s.io/v1'
ROOK_API_VERSION = 'ceph.rook.io/v1'
OCP_API_VERSION = 'project.openshift.io/v1'
OPENSHIFT_REST_CLIENT_API_VERSION = 'v1'
8 changes: 8 additions & 0 deletions ocsci/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
Avoid already-imported warning cause of we are importing this package from
run wrapper for loading config.
You can see documentation here:
https://docs.pytest.org/en/latest/reference.html
under section PYTEST_DONT_REWRITE
"""
20 changes: 12 additions & 8 deletions ocsci/config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Following config variables will be loaded by ocscilib pytest plugin.
# See the conf/ocsci/default_config.yaml for default values.
# The data are combined from multiple sources and then exposed to the following
# variables.
#
# You can see the logic in ./pytest_customization/plugins/ocscilib.py.
"""
Following config variables will be loaded by ocscilib pytest plugin.
See the conf/ocsci/default_config.yaml for default values.
The data are combined from multiple sources and then exposed to the following
variables.
# Those have lowest priority and are overwritten and filled with data loaded
# during the config phase.
You can see the logic in ./pytest_customization/plugins/ocscilib.py.
Those have lowest priority and are overwritten and filled with data loaded
during the config phase.
PYTEST_DONT_REWRITE - avoid pytest to rewrite, keep this msg here please!
"""
RUN = dict(cli_params={}) # this will be filled with CLI parameters data
DEPLOYMENT = {} # deployment related data
REPORTING = {} # reporting related data
Expand Down

0 comments on commit 6d74951

Please sign in to comment.