Skip to content

Commit 1d1ff72

Browse files
committed
Fix format
1 parent d537a59 commit 1d1ff72

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

tests/test_ping.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def test_add_ip_invalid(self):
162162
command = ping._add_ip("invalid_ip")
163163
assert command is None
164164

165-
@patch('subprocess.Popen')
165+
@patch("subprocess.Popen")
166166
def test_ping_valid_ip(self, mock_popen):
167167
"""Test ping method with valid IP"""
168168
mock_process = MagicMock()
@@ -172,7 +172,7 @@ def test_ping_valid_ip(self, mock_popen):
172172
b"--- 8.8.8.8 ping statistics ---\n"
173173
b"1 packets transmitted, 1 received, 0% packet loss, time 0ms\n"
174174
b"rtt min/avg/max/mdev = 20.100/20.100/20.100/0.000 ms\n",
175-
b""
175+
b"",
176176
)
177177
mock_popen.return_value = mock_process
178178

@@ -225,15 +225,15 @@ def test_tcping_initialization(self):
225225
"""Test tcping command initialization"""
226226
ping = Ping(command="tcping", layer=4)
227227
assert "tcping" in ping.command
228-
assert "-c 4" in ping.command or "-t" in ' '.join(ping.command)
228+
assert "-c 4" in ping.command or "-t" in " ".join(ping.command)
229229

230230
def test_ping_with_timeout(self):
231231
"""Test ping with custom timeout"""
232232
Ping(timeout=5)
233233
Ping(timeout=10)
234234
# Timeout should be in the command for layer 4
235235
ping_l4 = Ping(layer=4, timeout=5)
236-
assert "-t" in ' '.join(ping_l4.command) or "-t 5" in ping_l4.command
236+
assert "-t" in " ".join(ping_l4.command) or "-t 5" in ping_l4.command
237237

238238
def test_tcping_loss_percentage_calculation(self):
239239
"""Test tcping loss percentage calculation (line 78)"""
@@ -264,17 +264,17 @@ def test_run_with_valid_ip(self):
264264
"""Test run() function with valid IP address (lines 146-181)"""
265265
from pingping.ping import run
266266

267-
with patch('sys.argv', ['pingping', '8.8.8.8']):
268-
with patch.object(Ping, 'ping', return_value={'ip': '8.8.8.8'}):
267+
with patch("sys.argv", ["pingping", "8.8.8.8"]):
268+
with patch.object(Ping, "ping", return_value={"ip": "8.8.8.8"}):
269269
result = run()
270270
assert result is not None
271-
assert result['ip'] == '8.8.8.8'
271+
assert result["ip"] == "8.8.8.8"
272272

273273
def test_run_with_help_flag(self):
274274
"""Test run() function with -h flag (lines 146-181)"""
275275
from pingping.ping import run
276276

277-
with patch('sys.argv', ['pingping', '-h']):
277+
with patch("sys.argv", ["pingping", "-h"]):
278278
with pytest.raises(SystemExit) as exc_info:
279279
run()
280280
assert exc_info.value.code == -1
@@ -283,7 +283,7 @@ def test_run_with_help_long_flag(self):
283283
"""Test run() function with --help flag (lines 146-181)"""
284284
from pingping.ping import run
285285

286-
with patch('sys.argv', ['pingping', '--help']):
286+
with patch("sys.argv", ["pingping", "--help"]):
287287
with pytest.raises(SystemExit) as exc_info:
288288
run()
289289
assert exc_info.value.code == -1
@@ -292,53 +292,53 @@ def test_run_with_tcp_flag(self):
292292
"""Test run() function with -l4 flag (lines 146-181)"""
293293
from pingping.ping import run
294294

295-
with patch('sys.argv', ['pingping', '-l4', '192.168.1.1']):
296-
with patch.object(Ping, 'ping', return_value={'ip': '192.168.1.1'}):
295+
with patch("sys.argv", ["pingping", "-l4", "192.168.1.1"]):
296+
with patch.object(Ping, "ping", return_value={"ip": "192.168.1.1"}):
297297
result = run()
298298
assert result is not None
299299

300300
def test_run_with_web_flag(self):
301301
"""Test run() function with --web flag (lines 146-181)"""
302302
from pingping.ping import run
303303

304-
with patch('sys.argv', ['pingping', '--web', '192.168.1.1']):
305-
with patch.object(Ping, 'ping', return_value={'ip': '192.168.1.1'}):
304+
with patch("sys.argv", ["pingping", "--web", "192.168.1.1"]):
305+
with patch.object(Ping, "ping", return_value={"ip": "192.168.1.1"}):
306306
result = run()
307307
assert result is not None
308308

309309
def test_run_with_tcp_long_flag(self):
310310
"""Test run() function with --tcp flag (lines 146-181)"""
311311
from pingping.ping import run
312312

313-
with patch('sys.argv', ['pingping', '--tcp', '192.168.1.1']):
314-
with patch.object(Ping, 'ping', return_value={'ip': '192.168.1.1'}):
313+
with patch("sys.argv", ["pingping", "--tcp", "192.168.1.1"]):
314+
with patch.object(Ping, "ping", return_value={"ip": "192.168.1.1"}):
315315
result = run()
316316
assert result is not None
317317

318318
def test_run_with_http_flag(self):
319319
"""Test run() function with --http flag (lines 146-181)"""
320320
from pingping.ping import run
321321

322-
with patch('sys.argv', ['pingping', '--http', '192.168.1.1']):
323-
with patch.object(Ping, 'ping', return_value={'ip': '192.168.1.1'}):
322+
with patch("sys.argv", ["pingping", "--http", "192.168.1.1"]):
323+
with patch.object(Ping, "ping", return_value={"ip": "192.168.1.1"}):
324324
result = run()
325325
assert result is not None
326326

327327
def test_run_with_count_flag(self):
328328
"""Test run() function with -c flag (lines 146-181)"""
329329
from pingping.ping import run
330330

331-
with patch('sys.argv', ['pingping', '-c', '10', '8.8.8.8']):
332-
with patch.object(Ping, 'ping', return_value={'ip': '8.8.8.8'}):
331+
with patch("sys.argv", ["pingping", "-c", "10", "8.8.8.8"]):
332+
with patch.object(Ping, "ping", return_value={"ip": "8.8.8.8"}):
333333
result = run()
334334
assert result is not None
335335

336336
def test_run_with_count_long_flag(self):
337337
"""Test run() function with --count flag (lines 146-181)"""
338338
from pingping.ping import run
339339

340-
with patch('sys.argv', ['pingping', '--count', '15', '1.1.1.1']):
341-
with patch.object(Ping, 'ping', return_value={'ip': '1.1.1.1'}):
340+
with patch("sys.argv", ["pingping", "--count", "15", "1.1.1.1"]):
341+
with patch.object(Ping, "ping", return_value={"ip": "1.1.1.1"}):
342342
result = run()
343343
assert result is not None
344344

@@ -348,7 +348,7 @@ def test_run_with_no_ip_address(self):
348348

349349
# When -c flag is used but no valid IP is provided, it will create a default Ping
350350
# and attempt to ping None, which returns None (not a SystemExit)
351-
with patch('sys.argv', ['pingping', '--help', 'invalid']):
351+
with patch("sys.argv", ["pingping", "--help", "invalid"]):
352352
with pytest.raises(SystemExit) as exc_info:
353353
run()
354354
assert exc_info.value.code == -1
@@ -357,7 +357,7 @@ def test_run_with_no_arguments(self):
357357
"""Test run() function with no arguments (lines 146-181)"""
358358
from pingping.ping import run
359359

360-
with patch('sys.argv', ['pingping']):
360+
with patch("sys.argv", ["pingping"]):
361361
with pytest.raises(SystemExit) as exc_info:
362362
run()
363363
assert exc_info.value.code == -1

0 commit comments

Comments
 (0)