Skip to content
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
22 changes: 11 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.10"
python-version: "3.14"
- name: Lint code
run: |
make setup
Expand All @@ -25,9 +25,9 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python 3.10
uses: actions/setup-python@v5
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.10"
- name: Run all tests + code coverage
Expand All @@ -52,9 +52,9 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Run tests
Expand All @@ -72,9 +72,9 @@ jobs:
id-token: write # IMPORTANT: mandatory for trusted publishing
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.11
- name: Install pypa/build
Expand All @@ -89,7 +89,7 @@ jobs:
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
github.actor == github.repository_owner
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: python-package-distributions
path: dist/
Expand All @@ -98,4 +98,4 @@ jobs:
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
github.actor == github.repository_owner
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ setup:
pip install -r requirements-dev-ui.txt

format:
black httpdbg tests
black httpdbg tests --target-version py39

lint:
black --check httpdbg tests
black --check httpdbg tests --target-version py39
flake8 httpdbg tests

typing:
Expand Down
2 changes: 1 addition & 1 deletion httpdbg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.1.5"
__version__ = "2.1.6"

__all__ = ["export_html", "httprecord", "HTTPRecords"]

Expand Down
3 changes: 0 additions & 3 deletions httpdbg/exception.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-


class HttpdbgException(Exception):
"""An issue occurred in httpdbg."""

Expand Down
1 change: 0 additions & 1 deletion httpdbg/hooks/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
1 change: 0 additions & 1 deletion httpdbg/hooks/external.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from contextlib import contextmanager
from typing import Generator
import glob
Expand Down
1 change: 0 additions & 1 deletion httpdbg/hooks/fastapi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from collections.abc import Callable
from contextlib import contextmanager
import functools
Expand Down
1 change: 0 additions & 1 deletion httpdbg/hooks/flask.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from collections.abc import Callable
from contextlib import contextmanager
import functools
Expand Down
1 change: 0 additions & 1 deletion httpdbg/hooks/pytest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from collections.abc import Callable
from contextlib import contextmanager
from typing import Generator
Expand Down
1 change: 0 additions & 1 deletion httpdbg/hooks/starlette.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from collections.abc import Callable
from contextlib import contextmanager
from functools import wraps
Expand Down
1 change: 0 additions & 1 deletion httpdbg/hooks/unittest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from collections.abc import Callable
from contextlib import contextmanager
import inspect
Expand Down
1 change: 0 additions & 1 deletion httpdbg/hooks/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from collections.abc import Callable
import inspect
import typing
Expand Down
1 change: 0 additions & 1 deletion httpdbg/initiator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from collections.abc import Callable
from contextlib import contextmanager
import datetime
Expand Down
9 changes: 6 additions & 3 deletions httpdbg/mode_console.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
import code
from typing import Optional
from typing import Union

from httpdbg.records import HTTPRecords
Expand All @@ -18,7 +18,7 @@ def __init__(self, records: HTTPRecords, locals=None):
self.incomplete_block: bool = False
super().__init__(locals)

def push(self, line):
def push(self, line: str, filename: Optional[str] = None) -> bool:
if line: # if the line is empty, we don't add it in the history
if (
self.incomplete_block
Expand All @@ -43,7 +43,10 @@ def push(self, line):
full_label = ">>> " + "\n>>> ".join(latest_history)

with httpdbg_group(self.records, label, full_label):
self.incomplete_block = super().push(line)
if filename is None:
self.incomplete_block = super().push(line)
else:
self.incomplete_block = super().push(line, filename)

return self.incomplete_block

Expand Down
1 change: 0 additions & 1 deletion httpdbg/mode_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import runpy
from unittest.mock import patch
import sys
Expand Down
1 change: 0 additions & 1 deletion httpdbg/mode_script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import runpy
import sys
Expand Down
1 change: 0 additions & 1 deletion httpdbg/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from contextlib import contextmanager
from http.server import HTTPServer
import threading
Expand Down
1 change: 0 additions & 1 deletion httpdbg/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from http.cookies import SimpleCookie
import secrets
import string
Expand Down
1 change: 0 additions & 1 deletion httpdbg/webapp/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from json import JSONEncoder
import traceback
from typing import Any
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from itertools import count
import os

Expand Down
1 change: 0 additions & 1 deletion tests/demo_run_multiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import requests


BASE_URL = os.environ.get(
"HTTPDBG_TEST_MULTIPROCESS_BASE_URL", "http://localhost:4909/"
)
Expand Down
1 change: 0 additions & 1 deletion tests/demo_run_pytest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/demo_run_script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import sys

import requests
Expand Down
1 change: 0 additions & 1 deletion tests/initiator_pck/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-
from .initiator2.mod2 import fnc_async # noqa
from .initiator2.mod2 import fnc_in_subpackage # noqa
1 change: 0 additions & 1 deletion tests/initiator_pck/initiator2/initiator3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import requests


Expand Down
1 change: 0 additions & 1 deletion tests/initiator_pck/initiator2/mod2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import httpx
import requests

Expand Down
1 change: 0 additions & 1 deletion tests/initiator_pck/mod1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import requests


Expand Down
1 change: 0 additions & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import requests

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest

from httpdbg import __version__
Expand Down
1 change: 0 additions & 1 deletion tests/test_context_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from httpdbg import httprecord

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_hook_aiohttp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import json
import platform

Expand Down
1 change: 0 additions & 1 deletion tests/test_hook_httpx.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import json
import platform

Expand Down
1 change: 0 additions & 1 deletion tests/test_hook_pytest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_hook_requests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import json

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_hook_unittest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os

import pytest
Expand Down
5 changes: 1 addition & 4 deletions tests/test_hook_urllib3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
import json
from packaging import version
import pkg_resources

import pytest
import urllib3
Expand Down Expand Up @@ -246,8 +244,7 @@ def test_urllib3_get_empty_request_content(httpbin_both):
@pytest.mark.initiator
@pytest.mark.urllib3
@pytest.mark.skipif(
version.parse(pkg_resources.get_distribution("urllib3").version)
< version.parse("2.0.0"),
version.parse(urllib3.__version__) < version.parse("2.0.0"),
reason="only urllib3 v2",
)
def test_urllib3_v2_request(httpbin):
Expand Down
29 changes: 14 additions & 15 deletions tests/test_initiator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import asyncio
import platform

Expand All @@ -24,8 +23,8 @@ def test_initiator_script(httpbin):
assert initiator.label == 'requests.get(f"{httpbin.url}/get")'

assert (
'''test_initiator.py", line 19, in test_initiator_script
19. requests.get(f"{httpbin.url}/get")
'''test_initiator.py", line 18, in test_initiator_script
18. requests.get(f"{httpbin.url}/get")
----------
requests.api.get(
url="'''
Expand All @@ -35,18 +34,18 @@ def test_initiator_script(httpbin):
in initiator.short_stack
)

full_stack_ref = """test_initiator.py", line 19,
15. @pytest.mark.initiator
16. def test_initiator_script(httpbin):
17.
18. with httprecord() as records:
19. requests.get(f"{httpbin.url}/get") <====
20.
21. assert len(records) == 1
22. initiator = records.initiators[records[0].initiator_id]
23.
24. assert initiator.label == 'requests.get(f"{httpbin.url}/get")'
25.""" # noqa W291
full_stack_ref = """test_initiator.py", line 18,
14. @pytest.mark.initiator
15. def test_initiator_script(httpbin):
16.
17. with httprecord() as records:
18. requests.get(f"{httpbin.url}/get") <====
19.
20. assert len(records) == 1
21. initiator = records.initiators[records[0].initiator_id]
22.
23. assert initiator.label == 'requests.get(f"{httpbin.url}/get")'
24.""" # noqa W291
full_stack = initiator.stack[0]
assert (
full_stack_ref in full_stack
Expand Down
1 change: 0 additions & 1 deletion tests/test_mode_console.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest
import requests

Expand Down
1 change: 0 additions & 1 deletion tests/test_mode_module_pytest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_mode_script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_preview.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest

from httpdbg.preview import generate_preview
Expand Down
1 change: 0 additions & 1 deletion tests/test_pyhttpdbg_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import requests

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest
import requests

Expand Down
1 change: 0 additions & 1 deletion tests/ui/test_web.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import random

import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/ui/web/ui.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import niobium # noqa: F401 - niobium automatically patches selenium
from selenium.webdriver.common.by import By

Expand Down