From a187c81e0caf92ed52a380f262b6b5eabb399897 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sat, 11 May 2019 14:45:59 -0700 Subject: [PATCH] Black + fix broken test --- tests/conftest.py | 13 +++++++++---- tests/test_inspect.py | 6 ++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index f6aa9952..33f9a472 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,7 +11,12 @@ def pytest_unconfigure(config): def pytest_collection_modifyitems(items): - # Ensure test_black.py runs first before any asyncio code kicks in - test_black = [fn for fn in items if fn.name == "test_black"] - if test_black: - items.insert(0, items.pop(items.index(test_black[0]))) + # Ensure test_black.py and test_inspect.py run first before any asyncio code kicks in + move_to_front(items, "test_black") + move_to_front(items, "test_inspect_cli") + + +def move_to_front(items, test_name): + test = [fn for fn in items if fn.name == test_name] + if test: + items.insert(0, items.pop(items.index(test[0]))) diff --git a/tests/test_inspect.py b/tests/test_inspect.py index da68652b..d039c162 100644 --- a/tests/test_inspect.py +++ b/tests/test_inspect.py @@ -15,14 +15,16 @@ def test_inspect_cli(app_client): assert 64 == len(database["hash"]) for table_name, expected_count in { "Table With Space In Name": 0, - "facetable": 15 + "facetable": 15, }.items(): assert expected_count == database["tables"][table_name]["count"] def test_inspect_cli_writes_to_file(app_client): runner = CliRunner() - result = runner.invoke(cli, ["inspect", "fixtures.db", "--inspect-file", "foo.json"]) + result = runner.invoke( + cli, ["inspect", "fixtures.db", "--inspect-file", "foo.json"] + ) assert 0 == result.exit_code, result.output data = json.load(open("foo.json")) assert ["fixtures"] == list(data.keys())