Skip to content

Commit

Permalink
Fix filtering in renew_fixtures command
Browse files Browse the repository at this point in the history
- Use `all_fixtures` (filtered) rather than `fixtures_registry` (unfiltered)
- If only one option filtered do that without asking for user input.
  • Loading branch information
phihag committed Jun 21, 2024
1 parent 661292c commit 05cebb8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bx_django_utils/test_utils/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)')
Expand Down

0 comments on commit 05cebb8

Please sign in to comment.