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

setUp (and tearDown) not affected by freeze_time on TestCase #57

Closed
eternicode opened this issue Sep 30, 2014 · 1 comment
Closed

setUp (and tearDown) not affected by freeze_time on TestCase #57

eternicode opened this issue Sep 30, 2014 · 1 comment

Comments

@eternicode
Copy link
Contributor

When writing a unittest TestCase with @freeze_time, datetime.now() inside the setUp method returns the current time instead of the frozen time. Also affects tearDown.

@freeze_time('2014-03-15 12:00 pm')
class TestSetupTime(unittest.TestCase):
  def setUp(self):
    print 'setup', datetime.now()

  def tearDown(self):
    print 'teardown', datetime.now()

  def test_time(self):
    print 'test', datetime.now()
setup 2014-09-30 17:21:52.945426
test 2014-03-15 12:00:00
teardown 2014-09-30 17:21:53.152456
@spulec
Copy link
Owner

spulec commented Oct 12, 2014

Sorry about that. I've changed the class-based decorator to impact all non-private methods now.

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