From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- third_party/python/mock-1.0.0/html/sentinel.html | 156 +++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 third_party/python/mock-1.0.0/html/sentinel.html (limited to 'third_party/python/mock-1.0.0/html/sentinel.html') diff --git a/third_party/python/mock-1.0.0/html/sentinel.html b/third_party/python/mock-1.0.0/html/sentinel.html new file mode 100644 index 0000000000..5b28deb2c5 --- /dev/null +++ b/third_party/python/mock-1.0.0/html/sentinel.html @@ -0,0 +1,156 @@ + + + + + + + + + Sentinel — Mock 1.0.0 documentation + + + + + + + + + + + + + + + +
+
+
+
+ +
+

Sentinel

+
+
+sentinel
+

The sentinel object provides a convenient way of providing unique +objects for your tests.

+

Attributes are created on demand when you access them by name. Accessing +the same attribute will always return the same object. The objects +returned have a sensible repr so that test failure messages are readable.

+
+ +
+
+DEFAULT
+

The DEFAULT object is a pre-created sentinel (actually +sentinel.DEFAULT). It can be used by side_effect +functions to indicate that the normal return value should be used.

+
+ +
+

Sentinel Example

+

Sometimes when testing you need to test that a specific object is passed as an +argument to another method, or returned. It can be common to create named +sentinel objects to test this. sentinel provides a convenient way of +creating and testing the identity of objects like this.

+

In this example we monkey patch method to return +sentinel.some_object:

+
>>> real = ProductionClass()
+>>> real.method = Mock(name="method")
+>>> real.method.return_value = sentinel.some_object
+>>> result = real.method()
+>>> assert result is sentinel.some_object
+>>> sentinel.some_object
+sentinel.some_object
+
+
+
+
+ + +
+
+
+
+
+

Table Of Contents

+ + +

Previous topic

+

Helpers

+

Next topic

+

Mocking Magic Methods

+

This Page

+ + + +
+
+
+
+ + + + \ No newline at end of file -- cgit v1.2.3