@@ -310,3 +310,65 @@ def test_pass():
310
310
'--slack_failed_emoji' , slack_hook_icon_emoji ,
311
311
'--only_failed' , True )
312
312
assert mock_post .call_args is None
313
+
314
+
315
+ def test_xdist_count (testdir ):
316
+ """Make sure that our pytest-messenger works."""
317
+
318
+ testdir .makepyfile (
319
+ """
320
+ import pytest
321
+ def test_pass_1():
322
+ assert 1 == 1
323
+
324
+ def test_pass_2():
325
+ assert 1 == 1
326
+
327
+ def test_pass_3():
328
+ assert 1 == 1
329
+
330
+ def test_pass_4():
331
+ assert 1 == 1
332
+
333
+ def test_pass_5():
334
+ assert 1 == 1
335
+
336
+ def test_pass_6():
337
+ assert 1 == 1
338
+
339
+ def test_pass_7():
340
+ assert 1 == 1
341
+
342
+ def test_fail_8():
343
+ assert 1 == 0
344
+ """
345
+ )
346
+
347
+ slack_hook_host = 'http://test.com/any_hash'
348
+ slack_hook_username = 'regression Testing'
349
+ slack_hook_report_host = 'http://report_link.com'
350
+ slack_hook_channel = 'test'
351
+ slack_hook_icon_emoji = ':thumbsdown:'
352
+ expected_text = '<http://report_link.com|Passed=7 Failed=1 Skipped=0 Error=0 XFailed=0 XPassed=0>'
353
+ with mock .patch ('requests.post' ) as mock_post :
354
+ testdir .runpytest ('-n' , '2' ,
355
+ '--slack_channel' , slack_hook_channel ,
356
+ '--slack_hook' , slack_hook_host ,
357
+ '--slack_report_link' , slack_hook_report_host ,
358
+ '--slack_username' , slack_hook_username ,
359
+ '--slack_failed_emoji' , slack_hook_icon_emoji )
360
+
361
+ called_data = json .loads (mock_post .call_args [1 ]['data' ])
362
+ called_host = mock_post .call_args [0 ][0 ]
363
+ called_channel = called_data ['channel' ]
364
+ called_username = called_data ['username' ]
365
+ text = called_data ['attachments' ][0 ]['text' ]
366
+ color = called_data ['attachments' ][0 ]['color' ]
367
+ emoji = called_data ['icon_emoji' ]
368
+
369
+ assert called_host == slack_hook_host
370
+ assert text == expected_text
371
+ assert called_channel == slack_hook_channel
372
+ assert called_username == slack_hook_username
373
+ assert color == '#ff0000'
374
+ assert emoji == slack_hook_icon_emoji
0 commit comments