Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c9cfcf1

Browse files
committed
#17351: merge with 3.2.
2 parents 3300878 + af8838f commit c9cfcf1

7 files changed

Lines changed: 23 additions & 22 deletions

File tree

Doc/howto/logging-cookbook.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ arbitrary object as a message format string, and that the logging package will
10361036
call ``str()`` on that object to get the actual format string. Consider the
10371037
following two classes::
10381038

1039-
class BraceMessage(object):
1039+
class BraceMessage:
10401040
def __init__(self, fmt, *args, **kwargs):
10411041
self.fmt = fmt
10421042
self.args = args
@@ -1045,7 +1045,7 @@ following two classes::
10451045
def __str__(self):
10461046
return self.fmt.format(*self.args, **self.kwargs)
10471047

1048-
class DollarMessage(object):
1048+
class DollarMessage:
10491049
def __init__(self, fmt, **kwargs):
10501050
self.fmt = fmt
10511051
self.kwargs = kwargs
@@ -1372,7 +1372,7 @@ works::
13721372
import random
13731373
import time
13741374

1375-
class MyHandler(object):
1375+
class MyHandler:
13761376
"""
13771377
A simple handler for logging events. It runs in the listener process and
13781378
dispatches events to loggers based on the name in the received record,

Doc/howto/sorting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function. The following wrapper makes that easy to do::
225225

226226
def cmp_to_key(mycmp):
227227
'Convert a cmp= function into a key= function'
228-
class K(object):
228+
class K:
229229
def __init__(self, obj, *args):
230230
self.obj = obj
231231
def __lt__(self, other):

Doc/library/contextlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ and maps them to the context management protocol::
361361

362362
from contextlib import contextmanager, ExitStack
363363

364-
class ResourceManager(object):
364+
class ResourceManager:
365365

366366
def __init__(self, acquire_resource, release_resource, check_resource_ok=None):
367367
self.acquire_resource = acquire_resource

Doc/library/functions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ are always available. They are listed here in alphabetical order.
324324
'__initializing__', '__loader__', '__name__', '__package__',
325325
'_clearcache', 'calcsize', 'error', 'pack', 'pack_into',
326326
'unpack', 'unpack_from']
327-
>>> class Shape(object):
327+
>>> class Shape:
328328
... def __dir__(self):
329329
... return ['area', 'perimeter', 'location']
330330
>>> s = Shape()

Doc/library/unittest.mock-examples.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ the correct arguments.
4545
This example tests that calling `ProductionClass().method` results in a call to
4646
the `something` method:
4747

48-
>>> class ProductionClass(object):
48+
>>> class ProductionClass:
4949
... def method(self):
5050
... self.something(1, 2, 3)
5151
... def something(self, a, b, c):
@@ -69,7 +69,7 @@ in the correct way.
6969
The simple `ProductionClass` below has a `closer` method. If it is called with
7070
an object then it calls `close` on it.
7171

72-
>>> class ProductionClass(object):
72+
>>> class ProductionClass:
7373
... def closer(self, something):
7474
... something.close()
7575
...
@@ -398,7 +398,7 @@ ends:
398398
Where you use `patch` to create a mock for you, you can get a reference to the
399399
mock using the "as" form of the with statement:
400400

401-
>>> class ProductionClass(object):
401+
>>> class ProductionClass:
402402
... def method(self):
403403
... pass
404404
...
@@ -446,7 +446,7 @@ testable way in the first place...
446446

447447
So, suppose we have some code that looks a little bit like this:
448448

449-
>>> class Something(object):
449+
>>> class Something:
450450
... def __init__(self):
451451
... self.backend = BackendProvider()
452452
... def method(self):
@@ -554,7 +554,7 @@ mock this using a `MagicMock`.
554554

555555
Here's an example class with an "iter" method implemented as a generator:
556556

557-
>>> class Foo(object):
557+
>>> class Foo:
558558
... def iter(self):
559559
... for i in [1, 2, 3]:
560560
... yield i
@@ -664,7 +664,7 @@ function will be turned into a bound method if it is fetched from an instance.
664664
It will have `self` passed in as the first argument, which is exactly what I
665665
wanted:
666666

667-
>>> class Foo(object):
667+
>>> class Foo:
668668
... def foo(self):
669669
... pass
670670
...
@@ -1183,7 +1183,7 @@ for us.
11831183
You can see in this example how a 'standard' call to `assert_called_with` isn't
11841184
sufficient:
11851185

1186-
>>> class Foo(object):
1186+
>>> class Foo:
11871187
... def __init__(self, a, b):
11881188
... self.a, self.b = a, b
11891189
...
@@ -1210,7 +1210,7 @@ A comparison function for our `Foo` class might look something like this:
12101210
And a matcher object that can use comparison functions like this for its
12111211
equality operation would look something like this:
12121212

1213-
>>> class Matcher(object):
1213+
>>> class Matcher:
12141214
... def __init__(self, compare, some_obj):
12151215
... self.compare = compare
12161216
... self.some_obj = some_obj

Doc/library/unittest.mock.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ have to create a dictionary and unpack it using `**`:
695695
Fetching a `PropertyMock` instance from an object calls the mock, with
696696
no args. Setting it calls the mock with the value being set.
697697

698-
>>> class Foo(object):
698+
>>> class Foo:
699699
... @property
700700
... def foo(self):
701701
... return 'something'
@@ -1031,7 +1031,7 @@ can set the `return_value` to be anything you want.
10311031
To configure return values on methods of *instances* on the patched class
10321032
you must do this on the `return_value`. For example:
10331033

1034-
>>> class Class(object):
1034+
>>> class Class:
10351035
... def method(self):
10361036
... pass
10371037
...
@@ -1204,7 +1204,7 @@ deleting and either iteration or membership test. This corresponds to the
12041204
magic methods `__getitem__`, `__setitem__`, `__delitem__` and either
12051205
`__iter__` or `__contains__`.
12061206

1207-
>>> class Container(object):
1207+
>>> class Container:
12081208
... def __init__(self):
12091209
... self.values = {}
12101210
... def __getitem__(self, name):
@@ -1378,7 +1378,7 @@ inform the patchers of the different prefix by setting `patch.TEST_PREFIX`:
13781378
>>> value = 3
13791379
>>>
13801380
>>> @patch('__main__.value', 'not three')
1381-
... class Thing(object):
1381+
... class Thing:
13821382
... def foo_one(self):
13831383
... print value
13841384
... def foo_two(self):
@@ -2137,7 +2137,7 @@ created in the `__init__` method and not to exist on the class at all.
21372137
`autospec` can't know about any dynamically created attributes and restricts
21382138
the api to visible attributes.
21392139

2140-
>>> class Something(object):
2140+
>>> class Something:
21412141
... def __init__(self):
21422142
... self.a = 33
21432143
...
@@ -2180,7 +2180,7 @@ class attributes (shared between instances of course) is faster too. e.g.
21802180

21812181
.. code-block:: python
21822182
2183-
class Something(object):
2183+
class Something:
21842184
a = 33
21852185
21862186
This brings up another issue. It is relatively common to provide a default
@@ -2191,7 +2191,7 @@ spec, and probably indicates a member that will normally of some other type,
21912191
`autospec` doesn't use a spec for members that are set to `None`. These will
21922192
just be ordinary mocks (well - `MagicMocks`):
21932193

2194-
>>> class Something(object):
2194+
>>> class Something:
21952195
... member = None
21962196
...
21972197
>>> mock = create_autospec(Something)
@@ -2206,7 +2206,7 @@ production class. Both of these require you to use an alternative object as
22062206
the spec. Thankfully `patch` supports this - you can simply pass the
22072207
alternative object as the `autospec` argument:
22082208

2209-
>>> class Something(object):
2209+
>>> class Something:
22102210
... def __init__(self):
22112211
... self.a = 33
22122212
...

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ Andrew Eland
331331
Julien Élie
332332
Lance Ellinghaus
333333
Daniel Ellis
334+
Phil Elson
334335
David Ely
335336
Jeff Epler
336337
Jeff McNeil

0 commit comments

Comments
 (0)