Skip to content

Commit 26e0725

Browse files
committed
chore: fix lint issues
ruff ruff ruff! Signed-off-by: Milas Bowman <milas.bowman@docker.com>
1 parent c9e3efd commit 26e0725

File tree

2 files changed

+111
-104
lines changed

2 files changed

+111
-104
lines changed

tests/integration/models_containers_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test_run_with_networking_config_with_undeclared_network(self):
157157
),
158158
}
159159

160-
with pytest.raises(docker.errors.APIError) as e:
160+
with pytest.raises(docker.errors.APIError):
161161
container = client.containers.run(
162162
'alpine', 'echo hello world', network=net_name,
163163
networking_config=networking_config,

tests/unit/models_containers_test.py

Lines changed: 110 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -41,96 +41,92 @@ def test_create_container_args(self):
4141
)
4242
}
4343

44-
create_kwargs = _create_container_args(dict(
45-
image='alpine',
46-
command='echo hello world',
47-
blkio_weight_device=[{'Path': 'foo', 'Weight': 3}],
48-
blkio_weight=2,
49-
cap_add=['foo'],
50-
cap_drop=['bar'],
51-
cgroup_parent='foobar',
52-
cgroupns='host',
53-
cpu_period=1,
54-
cpu_quota=2,
55-
cpu_shares=5,
56-
cpuset_cpus='0-3',
57-
detach=False,
58-
device_read_bps=[{'Path': 'foo', 'Rate': 3}],
59-
device_read_iops=[{'Path': 'foo', 'Rate': 3}],
60-
device_write_bps=[{'Path': 'foo', 'Rate': 3}],
61-
device_write_iops=[{'Path': 'foo', 'Rate': 3}],
62-
devices=['/dev/sda:/dev/xvda:rwm'],
63-
dns=['8.8.8.8'],
64-
domainname='example.com',
65-
dns_opt=['foo'],
66-
dns_search=['example.com'],
67-
entrypoint='/bin/sh',
68-
environment={'FOO': 'BAR'},
69-
extra_hosts={'foo': '1.2.3.4'},
70-
group_add=['blah'],
71-
ipc_mode='foo',
72-
kernel_memory=123,
73-
labels={'key': 'value'},
74-
links={'foo': 'bar'},
75-
log_config={'Type': 'json-file', 'Config': {}},
76-
lxc_conf={'foo': 'bar'},
77-
healthcheck={'test': 'true'},
78-
hostname='somehost',
79-
mac_address='abc123',
80-
mem_limit=123,
81-
mem_reservation=123,
82-
mem_swappiness=2,
83-
memswap_limit=456,
84-
name='somename',
85-
network_disabled=False,
86-
network='foo',
87-
networking_config=networking_config,
88-
oom_kill_disable=True,
89-
oom_score_adj=5,
90-
pid_mode='host',
91-
pids_limit=500,
92-
platform='linux',
93-
ports={
94-
1111: 4567,
95-
2222: None
96-
},
97-
privileged=True,
98-
publish_all_ports=True,
99-
read_only=True,
100-
restart_policy={'Name': 'always'},
101-
security_opt=['blah'],
102-
shm_size=123,
103-
stdin_open=True,
104-
stop_signal=9,
105-
sysctls={'foo': 'bar'},
106-
tmpfs={'/blah': ''},
107-
tty=True,
108-
ulimits=[{"Name": "nofile", "Soft": 1024, "Hard": 2048}],
109-
user='bob',
110-
userns_mode='host',
111-
uts_mode='host',
112-
version=DEFAULT_DOCKER_API_VERSION,
113-
volume_driver='some_driver',
114-
volumes=[
44+
create_kwargs = _create_container_args({
45+
'image': 'alpine',
46+
'command': 'echo hello world',
47+
'blkio_weight_device': [{'Path': 'foo', 'Weight': 3}],
48+
'blkio_weight': 2,
49+
'cap_add': ['foo'],
50+
'cap_drop': ['bar'],
51+
'cgroup_parent': 'foobar',
52+
'cgroupns': 'host',
53+
'cpu_period': 1,
54+
'cpu_quota': 2,
55+
'cpu_shares': 5,
56+
'cpuset_cpus': '0-3',
57+
'detach': False,
58+
'device_read_bps': [{'Path': 'foo', 'Rate': 3}],
59+
'device_read_iops': [{'Path': 'foo', 'Rate': 3}],
60+
'device_write_bps': [{'Path': 'foo', 'Rate': 3}],
61+
'device_write_iops': [{'Path': 'foo', 'Rate': 3}],
62+
'devices': ['/dev/sda:/dev/xvda:rwm'],
63+
'dns': ['8.8.8.8'],
64+
'domainname': 'example.com',
65+
'dns_opt': ['foo'],
66+
'dns_search': ['example.com'],
67+
'entrypoint': '/bin/sh',
68+
'environment': {'FOO': 'BAR'},
69+
'extra_hosts': {'foo': '1.2.3.4'},
70+
'group_add': ['blah'],
71+
'ipc_mode': 'foo',
72+
'kernel_memory': 123,
73+
'labels': {'key': 'value'},
74+
'links': {'foo': 'bar'},
75+
'log_config': {'Type': 'json-file', 'Config': {}},
76+
'lxc_conf': {'foo': 'bar'},
77+
'healthcheck': {'test': 'true'},
78+
'hostname': 'somehost',
79+
'mac_address': 'abc123',
80+
'mem_limit': 123,
81+
'mem_reservation': 123,
82+
'mem_swappiness': 2,
83+
'memswap_limit': 456,
84+
'name': 'somename',
85+
'network_disabled': False,
86+
'network': 'foo',
87+
'networking_config': networking_config,
88+
'oom_kill_disable': True,
89+
'oom_score_adj': 5,
90+
'pid_mode': 'host',
91+
'pids_limit': 500,
92+
'platform': 'linux',
93+
'ports': {1111: 4567, 2222: None},
94+
'privileged': True,
95+
'publish_all_ports': True,
96+
'read_only': True,
97+
'restart_policy': {'Name': 'always'},
98+
'security_opt': ['blah'],
99+
'shm_size': 123,
100+
'stdin_open': True,
101+
'stop_signal': 9,
102+
'sysctls': {'foo': 'bar'},
103+
'tmpfs': {'/blah': ''},
104+
'tty': True,
105+
'ulimits': [{"Name": "nofile", "Soft": 1024, "Hard": 2048}],
106+
'user': 'bob',
107+
'userns_mode': 'host',
108+
'uts_mode': 'host',
109+
'version': DEFAULT_DOCKER_API_VERSION,
110+
'volume_driver': 'some_driver', 'volumes': [
115111
'/home/user1/:/mnt/vol2',
116112
'/var/www:/mnt/vol1:ro',
117113
'volumename:/mnt/vol3r',
118114
'/volumewithnohostpath',
119115
'/anothervolumewithnohostpath:ro',
120116
'C:\\windows\\path:D:\\hello\\world:rw'
121117
],
122-
volumes_from=['container'],
123-
working_dir='/code'
124-
))
118+
'volumes_from': ['container'],
119+
'working_dir': '/code',
120+
})
125121

126-
expected = dict(
127-
image='alpine',
128-
command='echo hello world',
129-
domainname='example.com',
130-
detach=False,
131-
entrypoint='/bin/sh',
132-
environment={'FOO': 'BAR'},
133-
host_config={
122+
expected = {
123+
'image': 'alpine',
124+
'command': 'echo hello world',
125+
'domainname': 'example.com',
126+
'detach': False,
127+
'entrypoint': '/bin/sh',
128+
'environment': {'FOO': 'BAR'},
129+
'host_config': {
134130
'Binds': [
135131
'/home/user1/:/mnt/vol2',
136132
'/var/www:/mnt/vol1:ro',
@@ -153,9 +149,13 @@ def test_create_container_args(self):
153149
'CpuQuota': 2,
154150
'CpuShares': 5,
155151
'CpusetCpus': '0-3',
156-
'Devices': [{'PathOnHost': '/dev/sda',
157-
'CgroupPermissions': 'rwm',
158-
'PathInContainer': '/dev/xvda'}],
152+
'Devices': [
153+
{
154+
'PathOnHost': '/dev/sda',
155+
'CgroupPermissions': 'rwm',
156+
'PathInContainer': '/dev/xvda',
157+
},
158+
],
159159
'Dns': ['8.8.8.8'],
160160
'DnsOptions': ['foo'],
161161
'DnsSearch': ['example.com'],
@@ -187,37 +187,44 @@ def test_create_container_args(self):
187187
'ShmSize': 123,
188188
'Sysctls': {'foo': 'bar'},
189189
'Tmpfs': {'/blah': ''},
190-
'Ulimits': [{"Name": "nofile", "Soft": 1024, "Hard": 2048}],
190+
'Ulimits': [
191+
{"Name": "nofile", "Soft": 1024, "Hard": 2048},
192+
],
191193
'UsernsMode': 'host',
192194
'UTSMode': 'host',
193195
'VolumeDriver': 'some_driver',
194196
'VolumesFrom': ['container'],
195197
},
196-
healthcheck={'test': 'true'},
197-
hostname='somehost',
198-
labels={'key': 'value'},
199-
mac_address='abc123',
200-
name='somename',
201-
network_disabled=False,
202-
networking_config={'EndpointsConfig': {
203-
'foo': {'Aliases': ['test'], 'DriverOpts': {'key1': 'a'}}}
198+
'healthcheck': {'test': 'true'},
199+
'hostname': 'somehost',
200+
'labels': {'key': 'value'},
201+
'mac_address': 'abc123',
202+
'name': 'somename',
203+
'network_disabled': False,
204+
'networking_config': {
205+
'EndpointsConfig': {
206+
'foo': {
207+
'Aliases': ['test'],
208+
'DriverOpts': {'key1': 'a'},
209+
},
210+
}
204211
},
205-
platform='linux',
206-
ports=[('1111', 'tcp'), ('2222', 'tcp')],
207-
stdin_open=True,
208-
stop_signal=9,
209-
tty=True,
210-
user='bob',
211-
volumes=[
212+
'platform': 'linux',
213+
'ports': [('1111', 'tcp'), ('2222', 'tcp')],
214+
'stdin_open': True,
215+
'stop_signal': 9,
216+
'tty': True,
217+
'user': 'bob',
218+
'volumes': [
212219
'/mnt/vol2',
213220
'/mnt/vol1',
214221
'/mnt/vol3r',
215222
'/volumewithnohostpath',
216223
'/anothervolumewithnohostpath',
217224
'D:\\hello\\world'
218225
],
219-
working_dir='/code'
220-
)
226+
'working_dir': '/code',
227+
}
221228

222229
assert create_kwargs == expected
223230

0 commit comments

Comments
 (0)