From 05cebb881cacfc73fd37e74f2349f8a0a5cca1dc Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Fri, 21 Jun 2024 09:28:59 +0200 Subject: [PATCH] Fix filtering in renew_fixtures command - Use `all_fixtures` (filtered) rather than `fixtures_registry` (unfiltered) - If only one option filtered do that without asking for user input. --- bx_django_utils/test_utils/fixtures.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bx_django_utils/test_utils/fixtures.py b/bx_django_utils/test_utils/fixtures.py index fe86fd5..db8b237 100644 --- a/bx_django_utils/test_utils/fixtures.py +++ b/bx_django_utils/test_utils/fixtures.py @@ -211,15 +211,15 @@ def handle(self, *args, **options): filter_rex = re.compile(filter_re) all_fixtures = [ fixtures - for fixtures in fixtures_registry + for fixtures in all_fixtures if filter_rex.search(fixtures.name) or filter_rex.search(fixtures.file_name) ] - if not options['all']: + if not options['all'] and len(all_fixtures) != 1: # Ask the user what fixtures should be updated. print('Please select:\n') fixture_map = {} - for number, fixtures in enumerate(fixtures_registry): + for number, fixtures in enumerate(all_fixtures): fixture_map[str(number)] = fixtures print(f'{number:>3} - {fixtures.name} - {fixtures.file_name}') print('\n(ENTER nothing for renew all fixtures)')