1
1
# -*- coding: utf-8 -*-
2
2
import glob
3
3
import os
4
- import pickle
5
4
import time
6
5
from typing import Optional
7
- import uuid
8
6
9
7
import pytest
10
8
@@ -100,10 +98,7 @@ def pytest_configure(config):
100
98
101
99
@pytest .hookimpl (hookwrapper = True )
102
100
def pytest_runtest_protocol (item : pytest .Item , nextitem : Optional [pytest .Item ]):
103
- if item .config .option .httpdbg or (
104
- ("HTTPDBG_SUBPROCESS_DIR" in os .environ )
105
- and ("PYTEST_XDIST_WORKER" in os .environ )
106
- ):
101
+ if item .config .option .httpdbg :
107
102
with httprecord (initiators = item .config .option .httpdbg_initiator ) as records :
108
103
# the record of the http requests has been enable using a pytest command line argument
109
104
# -> first, we stash the path to the log file
@@ -118,18 +113,6 @@ def pytest_runtest_protocol(item: pytest.Item, nextitem: Optional[pytest.Item]):
118
113
119
114
yield
120
115
121
- # pytest is executed using pyhttpdbg
122
- # -> we serialize the HTTPRecords object to share it with the main pyhttpdbg process
123
- if "HTTPDBG_SUBPROCESS_DIR" in os .environ :
124
- if "PYTEST_XDIST_WORKER" in os .environ :
125
- if len (records .requests ) > 0 :
126
- fname = f"{ os .environ ['HTTPDBG_SUBPROCESS_DIR' ]} /{ uuid .uuid1 ()} "
127
- with open (f"{ fname } .httpdbgrecords.tmp" , "wb" ) as f :
128
- pickle .dump (records , f )
129
- os .rename (
130
- f"{ fname } .httpdbgrecords.tmp" , f"{ fname } .httpdbgrecords"
131
- )
132
-
133
116
# the record of the http requests has been enable using a pytest command line argument
134
117
# -> we create a human readable file that contains all the HTTP requests recorded
135
118
if httpdbg_record_filename in item .stash :
0 commit comments