declarative-mocks 0.4.1__tar.gz → 0.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/PKG-INFO +9 -7
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/README.md +8 -6
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/pyproject.toml +1 -1
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/LICENSE +0 -0
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/src/dmock/__init__.py +0 -0
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/src/dmock/_exceptions.py +0 -0
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/src/dmock/_expectation.py +0 -0
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/src/dmock/_matchers.py +0 -0
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/src/dmock/_mock.py +0 -0
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/src/dmock/_protocols.py +0 -0
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/src/dmock/_pytest_plugin.py +0 -0
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/src/dmock/_registry.py +0 -0
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/src/dmock/_types.py +0 -0
- {declarative_mocks-0.4.1 → declarative_mocks-0.4.2}/src/dmock/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: declarative-mocks
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: Declare mock behavior as ordered expectations. Simple, typed, gomock-inspired DSL over unittest.mock
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -69,17 +69,19 @@ service = Mock(spec=Directory)
|
|
|
69
69
|
service.lookup.return_value = User(id=1, name="Ada", email="ada@example.com")
|
|
70
70
|
|
|
71
71
|
user = service.lookup("ada")
|
|
72
|
-
assert
|
|
73
|
-
assert user.name
|
|
74
|
-
assert "@"
|
|
72
|
+
assert user.id == 1
|
|
73
|
+
assert user.name == "Ada"
|
|
74
|
+
assert user.email == "ada@example.com"
|
|
75
75
|
assert abs((datetime.now() - user.created_at).total_seconds()) < 5
|
|
76
|
-
service.lookup.
|
|
76
|
+
name = service.lookup.call_args.args[0]
|
|
77
|
+
assert isinstance(name, str)
|
|
78
|
+
assert name.startswith("a")
|
|
77
79
|
```
|
|
78
80
|
|
|
79
81
|
Here's an example of how **dmock** improves your tests:
|
|
80
82
|
|
|
81
83
|
```python
|
|
82
|
-
from dmock import
|
|
84
|
+
from dmock import DeclarativeMock, IsNow, StartsWith
|
|
83
85
|
|
|
84
86
|
service = DeclarativeMock(Directory)
|
|
85
87
|
service.expect(Directory.lookup, StartsWith("a")).returns(
|
|
@@ -147,7 +149,7 @@ calc = DeclarativeMock(Calculator)
|
|
|
147
149
|
calc.expect("price", 100).returns(99).once()
|
|
148
150
|
assert calc.price(100) == 99
|
|
149
151
|
|
|
150
|
-
calc.expect("price", 200).returns(99).times(3) # last outcome repeats for the extra calls
|
|
152
|
+
calc.expect("price", 200).returns(99, repeat=2).times(3) # last outcome repeats for the extra calls
|
|
151
153
|
assert [calc.price(200) for _ in range(3)] == [99, 99, 99]
|
|
152
154
|
|
|
153
155
|
calc.expect("price", 300).returns(99).between(1, 3)
|
|
@@ -40,17 +40,19 @@ service = Mock(spec=Directory)
|
|
|
40
40
|
service.lookup.return_value = User(id=1, name="Ada", email="ada@example.com")
|
|
41
41
|
|
|
42
42
|
user = service.lookup("ada")
|
|
43
|
-
assert
|
|
44
|
-
assert user.name
|
|
45
|
-
assert "@"
|
|
43
|
+
assert user.id == 1
|
|
44
|
+
assert user.name == "Ada"
|
|
45
|
+
assert user.email == "ada@example.com"
|
|
46
46
|
assert abs((datetime.now() - user.created_at).total_seconds()) < 5
|
|
47
|
-
service.lookup.
|
|
47
|
+
name = service.lookup.call_args.args[0]
|
|
48
|
+
assert isinstance(name, str)
|
|
49
|
+
assert name.startswith("a")
|
|
48
50
|
```
|
|
49
51
|
|
|
50
52
|
Here's an example of how **dmock** improves your tests:
|
|
51
53
|
|
|
52
54
|
```python
|
|
53
|
-
from dmock import
|
|
55
|
+
from dmock import DeclarativeMock, IsNow, StartsWith
|
|
54
56
|
|
|
55
57
|
service = DeclarativeMock(Directory)
|
|
56
58
|
service.expect(Directory.lookup, StartsWith("a")).returns(
|
|
@@ -118,7 +120,7 @@ calc = DeclarativeMock(Calculator)
|
|
|
118
120
|
calc.expect("price", 100).returns(99).once()
|
|
119
121
|
assert calc.price(100) == 99
|
|
120
122
|
|
|
121
|
-
calc.expect("price", 200).returns(99).times(3) # last outcome repeats for the extra calls
|
|
123
|
+
calc.expect("price", 200).returns(99, repeat=2).times(3) # last outcome repeats for the extra calls
|
|
122
124
|
assert [calc.price(200) for _ in range(3)] == [99, 99, 99]
|
|
123
125
|
|
|
124
126
|
calc.expect("price", 300).returns(99).between(1, 3)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "declarative-mocks"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.2"
|
|
4
4
|
description = "Declare mock behavior as ordered expectations. Simple, typed, gomock-inspired DSL over unittest.mock"
|
|
5
5
|
authors = [{ name = "Dimitry Churilov", email = "d.mdx3r@gmail.com" }]
|
|
6
6
|
license = "MIT"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|