From 4a8fb6c43cfec1fa06218b2fb9c69453a5021f00 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Thu, 28 Dec 2023 19:16:11 +0530 Subject: [PATCH] style: format --- frappe/tests/test_hooks.py | 42 +++++++++++++++++++++++--------------- frappe/utils/fixtures.py | 4 +++- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/frappe/tests/test_hooks.py b/frappe/tests/test_hooks.py index c1fcd23982..14bd1affca 100644 --- a/frappe/tests/test_hooks.py +++ b/frappe/tests/test_hooks.py @@ -98,11 +98,12 @@ class TestHooks(FrappeTestCase): def test_fixture_prefix(self): import os import shutil + from frappe import hooks from frappe.utils.fixtures import export_fixtures app = "frappe" - if(os.path.isdir(frappe.get_app_path(app, "fixtures"))): + if os.path.isdir(frappe.get_app_path(app, "fixtures")): shutil.rmtree(frappe.get_app_path(app, "fixtures")) # use any set of core doctypes for test purposes @@ -118,16 +119,20 @@ class TestHooks(FrappeTestCase): if frappe._load_app_hooks.__wrapped__ in frappe.local.request_cache.keys(): del frappe.local.request_cache[frappe._load_app_hooks.__wrapped__] self.assertEqual([False], frappe.get_hooks("fixture_auto_order", app_name=app)) - self.assertEqual([ - {"dt": "User"}, - {"dt": "Contact"}, - {"dt": "Role"}, - ], frappe.get_hooks("fixtures", app_name=app)) + self.assertEqual( + [ + {"dt": "User"}, + {"dt": "Contact"}, + {"dt": "Role"}, + ], + frappe.get_hooks("fixtures", app_name=app), + ) export_fixtures(app) # use assertCountEqual (replaced assertItemsEqual), beacuse os.listdir might return the list in a different order, depending on OS - self.assertCountEqual(["user.json", "contact.json", "role.json"], os.listdir(frappe.get_app_path(app, "fixtures"))) - + self.assertCountEqual( + ["user.json", "contact.json", "role.json"], os.listdir(frappe.get_app_path(app, "fixtures")) + ) hooks.fixture_auto_order = True del frappe.local.request_cache[frappe._load_app_hooks.__wrapped__] @@ -135,13 +140,13 @@ class TestHooks(FrappeTestCase): shutil.rmtree(frappe.get_app_path(app, "fixtures")) export_fixtures(app) - self.assertCountEqual(["1_user.json", "2_contact.json", "3_role.json"], os.listdir(frappe.get_app_path(app, "fixtures"))) - + self.assertCountEqual( + ["1_user.json", "2_contact.json", "3_role.json"], + os.listdir(frappe.get_app_path(app, "fixtures")), + ) hooks.fixtures = [ - { - "dt": "User", - "prefix": "my_prefix"}, + {"dt": "User", "prefix": "my_prefix"}, {"dt": "Contact"}, {"dt": "Role"}, ] @@ -150,14 +155,19 @@ class TestHooks(FrappeTestCase): del frappe.local.request_cache[frappe._load_app_hooks.__wrapped__] shutil.rmtree(frappe.get_app_path(app, "fixtures")) export_fixtures(app) - self.assertCountEqual(["my_prefix_user.json", "contact.json", "role.json"], os.listdir(frappe.get_app_path(app, "fixtures"))) - + self.assertCountEqual( + ["my_prefix_user.json", "contact.json", "role.json"], + os.listdir(frappe.get_app_path(app, "fixtures")), + ) hooks.fixture_auto_order = True del frappe.local.request_cache[frappe._load_app_hooks.__wrapped__] shutil.rmtree(frappe.get_app_path(app, "fixtures")) export_fixtures(app) - self.assertCountEqual(["1_my_prefix_user.json", "2_contact.json", "3_role.json"], os.listdir(frappe.get_app_path(app, "fixtures"))) + self.assertCountEqual( + ["1_my_prefix_user.json", "2_contact.json", "3_role.json"], + os.listdir(frappe.get_app_path(app, "fixtures")), + ) class TestAPIHooks(FrappeAPITestCase): diff --git a/frappe/utils/fixtures.py b/frappe/utils/fixtures.py index 2a9fb541b6..120d452cc0 100644 --- a/frappe/utils/fixtures.py +++ b/frappe/utils/fixtures.py @@ -67,7 +67,9 @@ def export_fixtures(app=None): else: apps = frappe.get_installed_apps() for app in apps: - fixture_auto_order = bool(next(iter(frappe.get_hooks("fixture_auto_order", app_name=app)), False)) + fixture_auto_order = bool( + next(iter(frappe.get_hooks("fixture_auto_order", app_name=app)), False) + ) fixtures = frappe.get_hooks("fixtures", app_name=app) for index, fixture in enumerate(fixtures, start=1): filters = None