Skip to content

Commit 6d74951

Browse files
petr-baloghPrasadDesala
authored andcommitted
Remove warning of pytest for rewriting modules
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)
1 parent 1f6ac6c commit 6d74951

File tree

4 files changed

+48
-25
lines changed

4 files changed

+48
-25
lines changed

ocs/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
Avoid already-imported warning cause of we are importing this package from
3+
run wrapper for loading config.
4+
5+
You can see documentation here:
6+
https://docs.pytest.org/en/latest/reference.html
7+
under section PYTEST_DONT_REWRITE
8+
"""

ocs/defaults.py

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
"""
2-
Defaults module
2+
Defaults module.
3+
4+
This module is automatically loaded with variables defined in
5+
conf/ocsci/default_config.yaml in its DEFAULTS section.
6+
7+
If the variable can be used in some config file sections from ocsci/config.py
8+
module, plese put your defaults rather to mentioned default_config.yaml file!
9+
10+
See the documentation in conf/README.md file to understand this config file.
11+
12+
PYTEST_DONT_REWRITE - avoid pytest to rewrite, keep this msg here please!
313
"""
414
import os
515
from getpass import getuser
616

717
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
818
TOP_DIR = os.path.dirname(THIS_DIR)
919
TEMPLATE_DIR = os.path.join(TOP_DIR, "templates/ocs-deployment/")
20+
STORAGE_API_VERSION = 'storage.k8s.io/v1'
21+
ROOK_API_VERSION = 'ceph.rook.io/v1'
22+
OCP_API_VERSION = 'project.openshift.io/v1'
23+
OPENSHIFT_REST_CLIENT_API_VERSION = 'v1'
1024

11-
# This module is automatically loaded with variables defined in
12-
# conf/ocsci/default_config.yaml in its DEFAULTS section.
13-
# If the variable can be used in some config file sections from ocsci/config.py
14-
# module, plese put your defaults rather to mentioned default_config.yaml file!
15-
16-
# See the documentation in conf/README.md file to understand this config file.
17-
18-
# Those variables are duplicate at the moment from default_config.yaml and once
19-
# we drop support for old runner we will remove those variables from here and
20-
# will have them defined only on one place.
25+
# Those variables below are duplicate at the moment from default_config.yaml
26+
# and once we drop support for old runner we will remove those variables from
27+
# here and will have them defined only on one place.
2128

22-
# Be aware that variables defined below are not used anywhere in th config
23-
# files and their sections when we rendering config!
29+
# Be aware that variables defined above and below are not used anywhere in the
30+
# config files and their sections when we rendering config!
2431

2532
INSTALLER_VERSION = '4.1.0-rc.3'
2633
CLIENT_VERSION = INSTALLER_VERSION
@@ -44,7 +51,3 @@
4451
'ceph_image': CEPH_IMAGE,
4552
'rook_image': ROOK_IMAGE,
4653
}
47-
STORAGE_API_VERSION = 'storage.k8s.io/v1'
48-
ROOK_API_VERSION = 'ceph.rook.io/v1'
49-
OCP_API_VERSION = 'project.openshift.io/v1'
50-
OPENSHIFT_REST_CLIENT_API_VERSION = 'v1'

ocsci/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
Avoid already-imported warning cause of we are importing this package from
3+
run wrapper for loading config.
4+
5+
You can see documentation here:
6+
https://docs.pytest.org/en/latest/reference.html
7+
under section PYTEST_DONT_REWRITE
8+
"""

ocsci/config.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
# Following config variables will be loaded by ocscilib pytest plugin.
2-
# See the conf/ocsci/default_config.yaml for default values.
3-
# The data are combined from multiple sources and then exposed to the following
4-
# variables.
5-
#
6-
# You can see the logic in ./pytest_customization/plugins/ocscilib.py.
1+
"""
2+
Following config variables will be loaded by ocscilib pytest plugin.
3+
See the conf/ocsci/default_config.yaml for default values.
4+
The data are combined from multiple sources and then exposed to the following
5+
variables.
76
8-
# Those have lowest priority and are overwritten and filled with data loaded
9-
# during the config phase.
7+
You can see the logic in ./pytest_customization/plugins/ocscilib.py.
8+
9+
Those have lowest priority and are overwritten and filled with data loaded
10+
during the config phase.
11+
12+
PYTEST_DONT_REWRITE - avoid pytest to rewrite, keep this msg here please!
13+
"""
1014
RUN = dict(cli_params={}) # this will be filled with CLI parameters data
1115
DEPLOYMENT = {} # deployment related data
1216
REPORTING = {} # reporting related data

0 commit comments

Comments
 (0)