Skip to content

Commit

Permalink
style: whitespace & duplication in test fixtures
Browse files Browse the repository at this point in the history
git ls-files -z "tests/requests/**.py" | xargs -0 sed -i -e '/^cfg = Config()$/d' -e '/^from gunicorn.config import Config$/d' --
git ls-files -z "tests/requests/**.py" | xargs -0 sed -z -i -e "s/''"'/""/g' -e 's/"\n\+}/",\n}/g' -e 's/)\n\+    \]/),\n    ]/g' --
git ls-files -z "tests/requests/**.py" | xargs -0 python3 -m black --skip-string-normalization --line-length=120 --target-version=py37 --
git restore tests/requests/valid/{001..027}.py tests/requests/valid/{025_line,padding_01,100}.py tests/requests/invalid/{002,003,chunked_*,018,version_01,version_02,003c}.py tests/requests/invalid/{006..009}.py
  • Loading branch information
pajod committed Aug 18, 2024
1 parent c8a3c70 commit 8d2b5c2
Show file tree
Hide file tree
Showing 94 changed files with 125 additions and 172 deletions.
3 changes: 2 additions & 1 deletion tests/requests/invalid/001.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import NoMoreData
request = NoMoreData

request = NoMoreData
1 change: 1 addition & 0 deletions tests/requests/invalid/002.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidRequestLine

request = InvalidRequestLine
1 change: 1 addition & 0 deletions tests/requests/invalid/003.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidRequestLine

request = InvalidRequestLine
3 changes: 2 additions & 1 deletion tests/requests/invalid/003b.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidRequestMethod
request = InvalidRequestMethod

request = InvalidRequestMethod
1 change: 1 addition & 0 deletions tests/requests/invalid/003c.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidRequestMethod

request = InvalidRequestMethod
3 changes: 2 additions & 1 deletion tests/requests/invalid/004.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidHTTPVersion
request = InvalidHTTPVersion

request = InvalidHTTPVersion
3 changes: 2 additions & 1 deletion tests/requests/invalid/005.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidHeaderName
request = InvalidHeaderName

request = InvalidHeaderName
1 change: 1 addition & 0 deletions tests/requests/invalid/006.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import LimitRequestLine

request = LimitRequestLine
1 change: 1 addition & 0 deletions tests/requests/invalid/007.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import LimitRequestHeaders

request = LimitRequestHeaders
1 change: 1 addition & 0 deletions tests/requests/invalid/008.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import LimitRequestHeaders

request = LimitRequestHeaders
1 change: 1 addition & 0 deletions tests/requests/invalid/009.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import LimitRequestHeaders

request = LimitRequestHeaders
2 changes: 0 additions & 2 deletions tests/requests/invalid/010.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from gunicorn.config import Config
from gunicorn.http.errors import LimitRequestHeaders

request = LimitRequestHeaders
cfg = Config()
cfg.set('limit_request_field_size', 10)
2 changes: 0 additions & 2 deletions tests/requests/invalid/011.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from gunicorn.config import Config
from gunicorn.http.errors import LimitRequestHeaders

request = LimitRequestHeaders
cfg = Config()
cfg.set('limit_request_fields', 2)
2 changes: 0 additions & 2 deletions tests/requests/invalid/012.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from gunicorn.config import Config
from gunicorn.http.errors import LimitRequestHeaders

request = LimitRequestHeaders
cfg = Config()
cfg.set('limit_request_field_size', 98)
2 changes: 0 additions & 2 deletions tests/requests/invalid/013.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from gunicorn.config import Config
from gunicorn.http.errors import LimitRequestHeaders

request = LimitRequestHeaders
cfg = Config()
cfg.set('limit_request_field_size', 14)

# once this option is removed, this test should not be dropped;
Expand Down
2 changes: 0 additions & 2 deletions tests/requests/invalid/017.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import LimitRequestHeaders

cfg = Config()
request = LimitRequestHeaders
1 change: 1 addition & 0 deletions tests/requests/invalid/018.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidHTTPVersion

request = InvalidHTTPVersion
2 changes: 0 additions & 2 deletions tests/requests/invalid/019.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidSchemeHeaders

request = InvalidSchemeHeaders
cfg = Config()
cfg.set('forwarded_allow_ips', '*')
2 changes: 0 additions & 2 deletions tests/requests/invalid/020.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidHeaderName

cfg = Config()
request = InvalidHeaderName
2 changes: 0 additions & 2 deletions tests/requests/invalid/021.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidHeader

cfg = Config()
request = InvalidHeader
2 changes: 0 additions & 2 deletions tests/requests/invalid/022.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidHeader

cfg = Config()
request = InvalidHeader
2 changes: 0 additions & 2 deletions tests/requests/invalid/023.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidHeader

cfg = Config()
request = InvalidHeader
2 changes: 0 additions & 2 deletions tests/requests/invalid/024.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidHeader

cfg = Config()
request = InvalidHeader
2 changes: 0 additions & 2 deletions tests/requests/invalid/040.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from gunicorn.http.errors import InvalidHeaderName
from gunicorn.config import Config

cfg = Config()
cfg.set("header_map", "refuse")

request = InvalidHeaderName
1 change: 1 addition & 0 deletions tests/requests/invalid/chunked_01.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidChunkSize

request = InvalidChunkSize
1 change: 1 addition & 0 deletions tests/requests/invalid/chunked_02.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidHeader

request = InvalidHeader
5 changes: 3 additions & 2 deletions tests/requests/invalid/chunked_03.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidHeader
request = InvalidHeader
from gunicorn.http.errors import InvalidHeader

request = InvalidHeader
1 change: 1 addition & 0 deletions tests/requests/invalid/chunked_04.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidHeader

request = InvalidHeader
1 change: 1 addition & 0 deletions tests/requests/invalid/chunked_05.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidHeader

request = InvalidHeader
5 changes: 3 additions & 2 deletions tests/requests/invalid/chunked_06.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidHeader
request = InvalidHeader
from gunicorn.http.errors import InvalidHeader

request = InvalidHeader
2 changes: 0 additions & 2 deletions tests/requests/invalid/chunked_07.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from gunicorn.http.errors import InvalidHeaderName
from gunicorn.config import Config

cfg = Config()
cfg.set("header_map", "refuse")

request = InvalidHeaderName
1 change: 1 addition & 0 deletions tests/requests/invalid/chunked_08.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidHeader

request = InvalidHeader
1 change: 1 addition & 0 deletions tests/requests/invalid/chunked_09.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidChunkSize

request = InvalidChunkSize
1 change: 1 addition & 0 deletions tests/requests/invalid/chunked_10.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidChunkSize

request = InvalidChunkSize
1 change: 1 addition & 0 deletions tests/requests/invalid/chunked_11.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidChunkSize

request = InvalidChunkSize
1 change: 1 addition & 0 deletions tests/requests/invalid/chunked_12.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidChunkSize

request = InvalidChunkSize
1 change: 1 addition & 0 deletions tests/requests/invalid/chunked_13.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidChunkSize

request = InvalidChunkSize
2 changes: 0 additions & 2 deletions tests/requests/invalid/invalid_field_value_01.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidHeader

cfg = Config()
request = InvalidHeader
2 changes: 0 additions & 2 deletions tests/requests/invalid/nonascii_01.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidRequestMethod

cfg = Config()
request = InvalidRequestMethod
2 changes: 0 additions & 2 deletions tests/requests/invalid/nonascii_02.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidRequestMethod

cfg = Config()
request = InvalidRequestMethod
2 changes: 0 additions & 2 deletions tests/requests/invalid/nonascii_03.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidHeaderName

cfg = Config()
request = InvalidHeaderName
2 changes: 0 additions & 2 deletions tests/requests/invalid/nonascii_04.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidHeaderName

cfg = Config()
request = InvalidHeaderName
2 changes: 0 additions & 2 deletions tests/requests/invalid/pp_01.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidProxyLine

cfg = Config()
cfg.set("proxy_protocol", True)

request = InvalidProxyLine
2 changes: 0 additions & 2 deletions tests/requests/invalid/pp_02.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidProxyLine

cfg = Config()
cfg.set('proxy_protocol', True)

request = InvalidProxyLine
3 changes: 2 additions & 1 deletion tests/requests/invalid/prefix_01.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidRequestMethod
request = InvalidRequestMethod

request = InvalidRequestMethod
3 changes: 2 additions & 1 deletion tests/requests/invalid/prefix_02.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidRequestMethod
request = InvalidRequestMethod

request = InvalidRequestMethod
2 changes: 0 additions & 2 deletions tests/requests/invalid/prefix_03.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidHeader

cfg = Config()
request = InvalidHeader
2 changes: 0 additions & 2 deletions tests/requests/invalid/prefix_04.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidHeader

cfg = Config()
request = InvalidHeader
2 changes: 0 additions & 2 deletions tests/requests/invalid/prefix_05.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidRequestMethod

cfg = Config()
request = InvalidRequestMethod
2 changes: 0 additions & 2 deletions tests/requests/invalid/prefix_06.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gunicorn.config import Config
from gunicorn.http.errors import InvalidHTTPVersion

cfg = Config()
request = InvalidHTTPVersion
1 change: 1 addition & 0 deletions tests/requests/invalid/version_01.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidHTTPVersion

request = InvalidHTTPVersion
1 change: 1 addition & 0 deletions tests/requests/invalid/version_02.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from gunicorn.http.errors import InvalidHTTPVersion

request = InvalidHTTPVersion
4 changes: 2 additions & 2 deletions tests/requests/valid/001.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"headers": [
("SERVER", "http://127.0.0.1:5984"),
("CONTENT-TYPE", "application/json"),
("CONTENT-LENGTH", "14")
("CONTENT-LENGTH", "14"),
],
"body": b'{"nom": "nom"}'
"body": b'{"nom": "nom"}',
}
4 changes: 2 additions & 2 deletions tests/requests/valid/002.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"headers": [
("USER-AGENT", "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1"),
("HOST", "0.0.0.0=5000"),
("ACCEPT", "*/*")
("ACCEPT", "*/*"),
],
"body": b""
"body": b"",
}
4 changes: 2 additions & 2 deletions tests/requests/valid/003.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
("ACCEPT-ENCODING", "gzip,deflate"),
("ACCEPT-CHARSET", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"),
("KEEP-ALIVE", "300"),
("CONNECTION", "keep-alive")
("CONNECTION", "keep-alive"),
],
"body": b""
"body": b"",
}
4 changes: 2 additions & 2 deletions tests/requests/valid/004.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"uri": uri("/silly"),
"version": (1, 1),
"headers": [
("AAAAAAAAAAAAA", "++++++++++")
("AAAAAAAAAAAAA", "++++++++++"),
],
"body": b""
"body": b"",
}
2 changes: 1 addition & 1 deletion tests/requests/valid/005.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"uri": uri("/forums/1/topics/2375?page=1#posts-17408"),
"version": (1, 1),
"headers": [],
"body": b""
"body": b"",
}
2 changes: 1 addition & 1 deletion tests/requests/valid/006.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"uri": uri("/get_no_headers_no_body/world"),
"version": (1, 1),
"headers": [],
"body": b""
"body": b"",
}
4 changes: 2 additions & 2 deletions tests/requests/valid/007.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"uri": uri("/get_one_header_no_body"),
"version": (1, 1),
"headers": [
("ACCEPT", "*/*")
("ACCEPT", "*/*"),
],
"body": b""
"body": b"",
}
4 changes: 2 additions & 2 deletions tests/requests/valid/008.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"uri": uri("/unusual_content_length"),
"version": (1, 0),
"headers": [
("CONTENT-LENGTH", "5")
("CONTENT-LENGTH", "5"),
],
"body": b"HELLO"
"body": b"HELLO",
}
4 changes: 2 additions & 2 deletions tests/requests/valid/009.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"headers": [
("ACCEPT", "*/*"),
("TRANSFER-ENCODING", "identity"),
("CONTENT-LENGTH", "5")
("CONTENT-LENGTH", "5"),
],
"body": b"World"
"body": b"World",
}
2 changes: 1 addition & 1 deletion tests/requests/valid/010.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"headers": [
("TRANSFER-ENCODING", "chunked"),
],
"body": b"all your base are belong to us"
"body": b"all your base are belong to us",
}
4 changes: 2 additions & 2 deletions tests/requests/valid/011.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"uri": uri("/two_chunks_mult_zero_end"),
"version": (1, 1),
"headers": [
("TRANSFER-ENCODING", "chunked")
("TRANSFER-ENCODING", "chunked"),
],
"body": b"hello world"
"body": b"hello world",
}
Loading

0 comments on commit 8d2b5c2

Please sign in to comment.