Skip to content

Commit f98fa64

Browse files
authored
fix in case of no xdist (#9)
1 parent f2ed0ed commit f98fa64

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ classifiers = [
2424
]
2525
dynamic = ["version"]
2626
dependencies = [
27-
"httpdbg>=0.28.1",
27+
"httpdbg>=0.29.0",
2828
"pytest>=7.0.0"
2929
]
3030

3131
[tool.setuptools]
3232
packages = ["pytest_httpdbg"]
3333

3434
[tool.setuptools.dynamic]
35-
version = {attr = "pytest_httpdbg.VERSION"}
35+
version = {attr = "pytest_httpdbg.__version__"}
3636

3737
[project.urls]
3838
Source = "https://github.com/cle-b/pytest-httpdbg/"

pytest_httpdbg/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# -*- coding: utf-8 -*-
22
from pytest_httpdbg.plugin import httpdbg_record_filename # noqa F401
33

4-
VERSION = "0.5.0"
4+
__version__ = "0.6.0"

pytest_httpdbg/plugin.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ def content_type_md(content_type):
2929
return ct
3030

3131

32-
def record_to_md(record):
32+
def record_to_md(record, initiators):
3333
return f"""## {record.url}
3434
3535
### initiator
3636
37-
{record.initiator.short_label}
37+
{initiators[record.initiator_id].label}
3838
3939
```
40-
{record.initiator.short_stack}
40+
{initiators[record.initiator_id].short_stack}
4141
```
4242
4343
### request
@@ -100,7 +100,10 @@ def pytest_configure(config):
100100

101101
@pytest.hookimpl(hookwrapper=True)
102102
def pytest_runtest_protocol(item: pytest.Item, nextitem: Optional[pytest.Item]):
103-
if item.config.option.httpdbg or "HTTPDBG_SUBPROCESS_DIR" in os.environ:
103+
if item.config.option.httpdbg or (
104+
("HTTPDBG_SUBPROCESS_DIR" in os.environ)
105+
and ("PYTEST_XDIST_WORKER" in os.environ)
106+
):
104107
with httprecord(initiators=item.config.option.httpdbg_initiator) as records:
105108
# the record of the http requests has been enable using a pytest command line argument
106109
# -> first, we stash the path to the log file
@@ -135,6 +138,6 @@ def pytest_runtest_protocol(item: pytest.Item, nextitem: Optional[pytest.Item]):
135138
) as f:
136139
f.write(f"# {item.nodeid}\n\n")
137140
for record in records:
138-
f.write(f"{record_to_md(record)}\n")
141+
f.write(f"{record_to_md(record, records.initiators)}\n")
139142
else:
140143
yield

0 commit comments

Comments
 (0)