@@ -439,7 +439,10 @@ def test_integration_ok(tmp_path, capsys):
439
439
f .write_text (
440
440
"```python\n " "f(1, 2, 3)\n " "```\n " ,
441
441
)
442
- assert not blacken_docs .main ((str (f ),))
442
+
443
+ result = blacken_docs .main ((str (f ),))
444
+
445
+ assert result == 0
443
446
assert not capsys .readouterr ()[1 ]
444
447
assert f .read_text () == ("```python\n " "f(1, 2, 3)\n " "```\n " )
445
448
@@ -449,7 +452,10 @@ def test_integration_modifies(tmp_path, capsys):
449
452
f .write_text (
450
453
"```python\n " "f(1,2,3)\n " "```\n " ,
451
454
)
452
- assert blacken_docs .main ((str (f ),))
455
+
456
+ result = blacken_docs .main ((str (f ),))
457
+
458
+ assert result == 1
453
459
out , _ = capsys .readouterr ()
454
460
assert out == f"{ f } : Rewriting...\n "
455
461
assert f .read_text () == ("```python\n " "f(1, 2, 3)\n " "```\n " )
@@ -462,7 +468,10 @@ def test_integration_line_length(tmp_path):
462
468
"foo(very_very_very_very_very_very_very, long_long_long_long_long)\n "
463
469
"```\n " ,
464
470
)
465
- assert not blacken_docs .main ((str (f ), "--line-length=80" ))
471
+
472
+ result = blacken_docs .main ((str (f ), "--line-length=80" ))
473
+
474
+ assert result == 0
466
475
assert blacken_docs .main ((str (f ), "--line-length=50" ))
467
476
assert f .read_text () == (
468
477
"```python\n "
@@ -486,8 +495,13 @@ def test_integration_py36(tmp_path):
486
495
" pass\n "
487
496
"```\n " ,
488
497
)
489
- assert not blacken_docs .main ((str (f ),))
490
- assert blacken_docs .main ((str (f ), "--target-version=py36" ))
498
+
499
+ result = blacken_docs .main ((str (f ),))
500
+ assert result == 0
501
+
502
+ result2 = blacken_docs .main ((str (f ), "--target-version=py36" ))
503
+
504
+ assert result2 == 1
491
505
assert f .read_text () == (
492
506
"```python\n "
493
507
"def very_very_long_function_name(\n "
@@ -512,8 +526,13 @@ def test_integration_filename_last(tmp_path):
512
526
" pass\n "
513
527
"```\n " ,
514
528
)
515
- assert not blacken_docs .main ((str (f ),))
516
- assert blacken_docs .main (("--target-version" , "py36" , str (f )))
529
+
530
+ result = blacken_docs .main ((str (f ),))
531
+ assert result == 0
532
+
533
+ result2 = blacken_docs .main (("--target-version" , "py36" , str (f )))
534
+
535
+ assert result2 == 1
517
536
assert f .read_text () == (
518
537
"```python\n "
519
538
"def very_very_long_function_name(\n "
@@ -538,18 +557,25 @@ def test_integration_multiple_target_version(tmp_path):
538
557
" pass\n "
539
558
"```\n " ,
540
559
)
541
- assert not blacken_docs .main ((str (f ),))
542
- assert not blacken_docs .main (
560
+
561
+ result = blacken_docs .main ((str (f ),))
562
+ assert result == 0
563
+
564
+ result2 = blacken_docs .main (
543
565
("--target-version" , "py35" , "--target-version" , "py36" , str (f )),
544
566
)
567
+ assert result2 == 0
545
568
546
569
547
570
def test_integration_skip_string_normalization (tmp_path ):
548
571
f = tmp_path / "f.md"
549
572
f .write_text (
550
573
"```python\n " "f('hi')\n " "```\n " ,
551
574
)
552
- assert not blacken_docs .main ((str (f ), "--skip-string-normalization" ))
575
+
576
+ result = blacken_docs .main ((str (f ), "--skip-string-normalization" ))
577
+
578
+ assert result == 0
553
579
assert f .read_text () == ("```python\n " "f('hi')\n " "```\n " )
554
580
555
581
@@ -558,7 +584,10 @@ def test_integration_syntax_error(tmp_path, capsys):
558
584
f .write_text (
559
585
"```python\n " "f(\n " "```\n " ,
560
586
)
561
- assert blacken_docs .main ((str (f ),))
587
+
588
+ result = blacken_docs .main ((str (f ),))
589
+
590
+ assert result == 2
562
591
out , _ = capsys .readouterr ()
563
592
assert out .startswith (f"{ f } :1: code block parse error" )
564
593
assert f .read_text () == ("```python\n " "f(\n " "```\n " )
@@ -569,7 +598,10 @@ def test_integration_ignored_syntax_error(tmp_path, capsys):
569
598
f .write_text (
570
599
"```python\n " "f( )\n " "```\n " "\n " "```python\n " "f(\n " "```\n " ,
571
600
)
572
- assert blacken_docs .main ((str (f ), "--skip-errors" ))
601
+
602
+ result = blacken_docs .main ((str (f ), "--skip-errors" ))
603
+
604
+ assert result == 1
573
605
out , _ = capsys .readouterr ()
574
606
assert f .read_text () == (
575
607
"```python\n " "f()\n " "```\n " "\n " "```python\n " "f(\n " "```\n "
0 commit comments