Skip to content

Commit 71ffe67

Browse files
authored
Help the user to spot issues (#166)
* Help to detect `register()` misusage. * Bump version. * Improve DeepSource scans.
1 parent 13324a0 commit 71ffe67

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

.deepsource.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
version = 1
22

3+
test_patterns = [
4+
"tests/**",
5+
"test_*.py"
6+
]
7+
38
[[analyzers]]
49
name = "python"
510
enabled = true
11+
dependency_file_paths = ["requirements/development.txt"]
612

713
[analyzers.meta]
8-
runtime_version = "3.x.x"
14+
runtime_version = "3.x.x"
15+
type_checker = "mypy"
16+
max_line_length = 88
17+
skip_doc_coverage = ["module", "magic", "init"]
18+
additional_builtins = ["_", "pretty_output"]

mocket/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__all__ = ("mocketize", "Mocket", "MocketEntry", "Mocketizer")
44

5-
__version__ = "3.10.1"
5+
__version__ = "3.10.2"

mocket/mockhttp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ def _parse_requestline(line):
213213
@classmethod
214214
def register(cls, method, uri, *responses, **config):
215215

216+
if "body" in config or "status" in config:
217+
raise AttributeError("Did you mean `Entry.single_register(...)`?")
218+
216219
default_config = dict(match_querystring=True, add_trailing_slash=True)
217220
default_config.update(config)
218221
config = default_config

tests/main/test_http.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,3 +409,21 @@ def test_multi_register(self):
409409
response = requests.post(url, json={"test": 22})
410410
self.assertEqual(response.status_code, 202)
411411
self.assertEqual(response.json(), {"foo": "bar2"})
412+
413+
def test_suggestion_for_register_and_body(self):
414+
url = "http://foobar.com/path"
415+
with self.assertRaises(AttributeError):
416+
Entry.register(
417+
Entry.POST,
418+
url,
419+
body='{"foo":"bar0"}',
420+
)
421+
422+
def test_suggestion_for_register_and_status(self):
423+
url = "http://foobar.com/path"
424+
with self.assertRaises(AttributeError):
425+
Entry.register(
426+
Entry.POST,
427+
url,
428+
status=201,
429+
)

0 commit comments

Comments
 (0)