diff --git a/src/pytest_split/plugin.py b/src/pytest_split/plugin.py index fca0750..f65b9a6 100644 --- a/src/pytest_split/plugin.py +++ b/src/pytest_split/plugin.py @@ -214,7 +214,7 @@ def pytest_sessionfinish(self) -> None: self.cached_durations[k] = v with open(self.config.option.durations_path, "w") as f: - json.dump(self.cached_durations, f) + json.dump(self.cached_durations, f, sort_keys=True, indent=4) message = self.writer.markup( "\n\n[pytest-split] Stored test durations in {}".format(self.config.option.durations_path) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 82807cd..de2a923 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -30,6 +30,7 @@ def test_it_stores(self, example_suite, durations_path): assert list(durations.keys()) == [ "test_it_stores.py::test_1", + "test_it_stores.py::test_10", "test_it_stores.py::test_2", "test_it_stores.py::test_3", "test_it_stores.py::test_4", @@ -38,7 +39,6 @@ def test_it_stores(self, example_suite, durations_path): "test_it_stores.py::test_7", "test_it_stores.py::test_8", "test_it_stores.py::test_9", - "test_it_stores.py::test_10", ] for duration in durations.values():