Skip to content

remove xdist support #11

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

Merged
merged 1 commit into from
Feb 11, 2025
Merged
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
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "pytest-httpdbg"
authors = [
{name = "cle-b", email = "[email protected]"},
]
description="A pytest plugin to record HTTP(S) requests with stack trace"
description="A pytest plugin to record HTTP(S) requests with stack trace."
readme="README.md"
requires-python = ">=3.9.0"
license = {text = "Apache-2.0"}
Expand All @@ -24,7 +24,7 @@ classifiers = [
]
dynamic = ["version"]
dependencies = [
"httpdbg>=0.29.0",
"httpdbg>=0.32.0",
"pytest>=7.0.0"
]

Expand Down
2 changes: 1 addition & 1 deletion pytest_httpdbg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
from pytest_httpdbg.plugin import httpdbg_record_filename # noqa F401

__version__ = "0.6.1"
__version__ = "0.7.0"
19 changes: 1 addition & 18 deletions pytest_httpdbg/plugin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
import glob
import os
import pickle
import time
from typing import Optional
import uuid

import pytest

Expand Down Expand Up @@ -100,10 +98,7 @@ def pytest_configure(config):

@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_protocol(item: pytest.Item, nextitem: Optional[pytest.Item]):
if item.config.option.httpdbg or (
("HTTPDBG_SUBPROCESS_DIR" in os.environ)
and ("PYTEST_XDIST_WORKER" in os.environ)
):
if item.config.option.httpdbg:
with httprecord(initiators=item.config.option.httpdbg_initiator) as records:
# the record of the http requests has been enable using a pytest command line argument
# -> first, we stash the path to the log file
Expand All @@ -118,18 +113,6 @@ def pytest_runtest_protocol(item: pytest.Item, nextitem: Optional[pytest.Item]):

yield

# pytest is executed using pyhttpdbg
# -> we serialize the HTTPRecords object to share it with the main pyhttpdbg process
if "HTTPDBG_SUBPROCESS_DIR" in os.environ:
if "PYTEST_XDIST_WORKER" in os.environ:
if len(records.requests) > 0:
fname = f"{os.environ['HTTPDBG_SUBPROCESS_DIR']}/{uuid.uuid1()}"
with open(f"{fname}.httpdbgrecords.tmp", "wb") as f:
pickle.dump(records, f)
os.rename(
f"{fname}.httpdbgrecords.tmp", f"{fname}.httpdbgrecords"
)

# the record of the http requests has been enable using a pytest command line argument
# -> we create a human readable file that contains all the HTTP requests recorded
if httpdbg_record_filename in item.stash:
Expand Down