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

Fix and re-enable newer mitmproxy usage in tests. #6201

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

wRAR
Copy link
Member

@wRAR wRAR commented Jan 5, 2024

As usual, a two-character fix.

Fixes #5454.

@@ -46,7 +47,7 @@ def start(self):
stdout=PIPE,
)
line = self.proc.stdout.readline().decode("utf-8")
host_port = re.search(r"listening at http://([^:]+:\d+)", line).group(1)
host_port = re.search(r"listening at (?:http://)?([^:]+:\d+)", line).group(1)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output format has changed in some newer version but we can support both.

Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Merging #6201 (68fccb1) into master (40e623b) will decrease coverage by 0.02%.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6201      +/-   ##
==========================================
- Coverage   88.63%   88.61%   -0.02%     
==========================================
  Files         160      160              
  Lines       11615    11615              
  Branches     1890     1890              
==========================================
- Hits        10295    10293       -2     
- Misses        994      995       +1     
- Partials      326      327       +1     

see 2 files with indirect coverage changes

@@ -31,6 +31,7 @@ def start(self):
self.proc = Popen(
[
sys.executable,
"-u",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mitmproxy changed the code that prints log lines and we now need to disable stdout buffering to get it via Popen.

#mitmproxy >= 5.3.0; python_version >= '3.9' and implementation_name != 'pypy'
# The tests hang with mitmproxy 8.0.0: https://github.com/scrapy/scrapy/issues/5454
mitmproxy >= 4.0.4, < 8; python_version < '3.9' and implementation_name != 'pypy'
mitmproxy; implementation_name != 'pypy'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a minimal mitmproxy version, like >8?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code should work with any mitmproxy version.

@wRAR wRAR merged commit becff65 into scrapy:master Jan 12, 2024
26 checks passed
@wRAR wRAR deleted the more-mitmproxy branch January 12, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_proxy_connect.py hangs with mitmproxy 8.0.0 (affecting 3.8 tests)
2 participants