Commit 3c9a98b8 authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

Test that the source code satisfies the black code formatter.

parent 21d75462
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ Build-Depends:
 apktool [!ppc64el !s390x] <!nocheck>,
 bash-completion,
 binutils-multiarch <!nocheck>,
 black <!nocheck>,
 caca-utils <!nocheck>,
 colord <!nocheck>,
 db-util <!nocheck>,
+15 −0
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@
import os
import glob
import diffoscope
import subprocess

from .utils.tools import skip_unless_tools_exist

BASE_DIR = os.path.dirname(os.path.abspath(diffoscope.__file__))

@@ -28,3 +31,15 @@ def test_dos_mbr():
    for x in glob.iglob(os.path.join(BASE_DIR, '**', '*.py'), recursive=True):
        with open(x, 'rb') as f:
            assert b'DOS/MBR' not in f.read()


@skip_unless_tools_exist('black')
def test_code_is_black_clean():
    output = subprocess.check_output(
        ('black', '--diff', '.'), stderr=subprocess.PIPE
    ).decode('utf-8')

    # Display diff in "captured stdout call"
    print(output)

    assert len(output) == 0