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

Makes shortcuts a fixture #53

Merged
merged 1 commit into from Mar 6, 2023
Merged

Makes shortcuts a fixture #53

merged 1 commit into from Mar 6, 2023

Conversation

sobolevn
Copy link
Contributor

@sobolevn sobolevn commented Dec 6, 2019

I end up importing shortcuts in almost every module.
I guess, that it would much more convenient to use:

def test_with_some_date(fakery, shortcuts):
     ...

I hope this is a good idea :)

I end up importing `shortcuts` in almost every module.
I guess, that it would much more convenient to use:

```python
def test_with_some_date(fakery, shortcuts):
     ...
```

I hope this is a good idea :)
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 92.398% when pulling 02b0c26 on sobolevn:patch-1 into f071b59 on fcurella:master.

@fcurella
Copy link
Owner

fcurella commented Dec 6, 2019

I agree that there should a more convenient way to access the shortcuts, but I'm worried about name conflicts. I think shortcuts may be too generic of a name for a fixture. We could call it fakery_shortcuts, or something like that.

Alternatively, we could try just making the shortcuts module available as a property of Factory:

# faker_factory.py
from . import shortcuts


class Factory(Generic[T]):
    shortcurts = shortcuts

    # ... rest of the class

This way we just need one fixture:

def mytest(fakery):
    fakery.m(MyModel)(field=fakery.shortcuts.future_datetime('+1w'))

@fcurella fcurella merged commit c2ec4f1 into fcurella:master Mar 6, 2023
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

Successfully merging this pull request may close these issues.

None yet

3 participants