From f9193e7a18645397dc4c88b6b10bbcadc06d3fd4 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Fri, 3 May 2019 21:06:47 -0400 Subject: [PATCH] Unit test enforcing black formatting Only runs for Python 3.6 at the moment. See https://github.com/python/black/issues/425 --- setup.py | 1 + tests/test_black.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/test_black.py diff --git a/setup.py b/setup.py index 1e5397e9..11ad2fed 100644 --- a/setup.py +++ b/setup.py @@ -54,6 +54,7 @@ setup( "pytest-asyncio==0.10.0", "aiohttp==3.5.3", "beautifulsoup4==4.6.1", + "black", ] }, tests_require=["datasette[test]"], diff --git a/tests/test_black.py b/tests/test_black.py new file mode 100644 index 00000000..37fca5a6 --- /dev/null +++ b/tests/test_black.py @@ -0,0 +1,19 @@ +import black +from click.testing import CliRunner +from pathlib import Path +import pytest +import sys + +code_root = Path(__file__).parent.parent + + +# @pytest.mark.skipif( +# sys.version_info[:2] > (3, 6), +# reason="Breaks on 3.7 at the moment, but it only needs to run under one Python version", +# ) +def test_black(): + runner = CliRunner() + result = runner.invoke( + black.main, [str(code_root / "tests"), str(code_root / "datasette"), "--check"] + ) + assert result.exit_code == 0, result.output