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

Added as_kwarg argument #353

Merged
merged 2 commits into from May 28, 2020
Merged

Added as_kwarg argument #353

merged 2 commits into from May 28, 2020

Conversation

WisdomPill
Copy link
Contributor

@WisdomPill WisdomPill commented May 28, 2020

Closes #262

Added as_kwarg argument in order to have the frozen time object passed with the name provided in as_kwarg argument. Like the following

class TestUnitTestMethodDecorator(unittest.TestCase):
    @freeze_time('2013-04-09')
    def test_method_decorator_works_on_unittest(self):
        self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today())

    @freeze_time('2013-04-09', as_kwarg='frozen_time')
    def test_method_decorator_works_on_unittest(self, frozen_time):
        self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today())
        self.assertEqual(datetime.date(2013, 4, 9), frozen_time.time_to_freeze.today())

    @freeze_time('2013-04-09', as_kwarg='hello')
    def test_method_decorator_works_on_unittest(self, **kwargs):
        self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today())
        self.assertEqual(datetime.date(2013, 4, 9), kwargs.get('hello').time_to_freeze.today())

@coveralls
Copy link

coveralls commented May 28, 2020

Coverage Status

Coverage decreased (-0.1%) to 93.333% when pulling 6cfbc48 on WisdomPill:as_kwarg into 181f7ac on spulec:master.

freezegun/api.py Outdated Show resolved Hide resolved
@boxed boxed merged commit a57f61f into spulec:master May 28, 2020
@boxed
Copy link
Contributor

boxed commented May 28, 2020

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

Successfully merging this pull request may close these issues.

as_arg adds frozen_time argument to front of list of arguments
3 participants