Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: IQE-3400: drop _ibutsu compat #74

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 6 additions & 54 deletions src/pytest_ibutsu/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,28 +102,9 @@ class TestRun:
_start_unix_time: float = field(init=False, default=0.0)
_artifacts: Dict[str, Union[bytes, str]] = field(factory=dict)
summary: Summary = field(factory=Summary)
# TODO backwards compatibility
_data: Dict = field(factory=dict)

def __getitem__(self, key):
# TODO backwards compatibility
warnings.warn(
f'_ibutsu["{key}"] will be deprecated in pytest-ibutsu 3.0. '
"Please use a corresponding TestRun field.",
DeprecationWarning,
stacklevel=2,
)
return self._data[key]

def __setitem__(self, key, value):
# TODO backwards compatibility
warnings.warn(
f'_ibutsu["{key}"] will be deprecated in 3.0. '
"Please use a corresponding TestRun field.",
DeprecationWarning,
stacklevel=2,
)
self._data[key] = value




def __attrs_post_init__(self) -> None:
if os.getenv("JOB_NAME") and os.getenv("BUILD_NUMBER"):
Expand All @@ -134,9 +115,6 @@ def __attrs_post_init__(self) -> None:
}
if os.getenv("IBUTSU_ENV_ID"):
self.metadata["env_id"] = os.getenv("IBUTSU_ENV_ID")
# TODO backwards compatibility
self._data["metadata"] = {}

def start_timer(self) -> None:
self._start_unix_time = time.time()
self.start_time = datetime.utcnow().isoformat()
Expand Down Expand Up @@ -229,35 +207,9 @@ class TestResult:
start_time: str = ""
duration: float = 0.0
_artifacts: Dict[str, Union[bytes, str]] = field(factory=dict)
# TODO backwards compatibility
_data: Dict = field(factory=dict)

def __getitem__(self, key):
# TODO backwards compatibility
warnings.warn(
f'_ibutsu["{key}"] will be deprecated in pytest-ibutsu 3.0. '
"Please use a corresponding TestResult field.",
DeprecationWarning,
)
return self._data[key]

def __setitem__(self, key, value):
# TODO backwards compatibility
warnings.warn(
f'_ibutsu["{key}"] will be deprecated in pytest-ibutsu 3.0. '
"Please use a corresponding TestResult field.",
DeprecationWarning,
)
self._data[key] = value

def get(self, key: str, default=None):
# TODO backwards compatibility
warnings.warn(
f'_ibutsu.get("{key}") will be deprecated in pytest-ibutsu 3.0. '
"Please use a corresponding TestResult field.",
DeprecationWarning,
)
return self._data.get(key, default)




@staticmethod
def _get_item_params(item: pytest.Item) -> Dict:
Expand Down
13 changes: 1 addition & 12 deletions src/pytest_ibutsu/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,7 @@ def pytest_collection_modifyitems(
for item in items:
result = TestResult.from_item(item)
item.stash[ibutsu_result_key] = result
# TODO backwards compatibility
item._ibutsu = { # type: ignore
"id": item.stash[ibutsu_result_key].id,
"data": {"metadata": {}},
"artifacts": {},
}


def pytest_collection_finish(self, session: pytest.Session) -> None:
if not self.enabled:
Expand Down Expand Up @@ -293,10 +288,6 @@ def pytest_runtest_makereport(self, item, call):
"""Backward compatibility hook to merge metadata from item._ibutsu["data"]["metadata"]"""
if not self.enabled:
return
# TODO backwards compatibility
metadata = getattr(item, "_ibutsu", {}).get("data", {}).get("metadata", {})
# TODO backwards compatibility
merge_dicts(metadata, item.stash[ibutsu_result_key].metadata)

def pytest_runtest_logfinish(self, nodeid: str) -> None:
if not self.enabled or nodeid not in self.results:
Expand Down Expand Up @@ -421,5 +412,3 @@ def pytest_configure(config: pytest.Config) -> None:
plugin = IbutsuPlugin.from_config(config)
config.pluginmanager.register(plugin)
config.stash[ibutsu_plugin_key] = plugin
# TODO backwards compatibility
config._ibutsu = plugin # type: ignore
Loading