Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import_fixtures from multiple case modules #295

Closed
hans-d opened this issue Mar 2, 2023 · 2 comments
Closed

import_fixtures from multiple case modules #295

hans-d opened this issue Mar 2, 2023 · 2 comments

Comments

@hans-d
Copy link

hans-d commented Mar 2, 2023

The flag import_fixtures (see also #193) works nice when importing fixtures from an external file.

@parametrize_with_cases(
        'a,b',
        cases=COLLECTED_CASES,
        prefix='abc_',
        import_fixtures=True,
    )

Or, in my case, picking up cases decorated with @parametrize_with_cases

@parametrize_with_cases('given_config', cases='.', prefix='config_')
def abc_sometesting(given_config):
    # do some extra work
    return given_config

However, when COLLECTED_CASES has multiple modules (files), it borks on methods using the same name.

E   ValueError: Cannot import fixture <function X.config_same_name at 0x1213120c0> from <module '.cases_x' from blah> as it would override an existing symbol in <module 'tests.collecting' from blah>. Please set `@parametrize_with_cases(import_fixtures=False)`

Wrapping them in classes wont help either. Would be nice to have those imported fixtures prefixed with something unique per module (might be a short code, as somewhere that code can be mapped to the full module).

@hans-d
Copy link
Author

hans-d commented Mar 2, 2023

seems to be caused by something else (function returning a tuple like value)

@hans-d hans-d closed this as completed Mar 2, 2023
@smarie
Copy link
Owner

smarie commented Mar 3, 2023

Ok @hans-d ! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants