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

Cannot re-run tests when using freezegun #31

Open
andrewmichaelsmith opened this issue Aug 25, 2015 · 0 comments
Open

Cannot re-run tests when using freezegun #31

andrewmichaelsmith opened this issue Aug 25, 2015 · 0 comments

Comments

@andrewmichaelsmith
Copy link

I can't use the python package freezegun with my tests and sniffer, I get the issue below.

To reproduce:

Create a file tests.py:

import unittest
from freezegun import freeze_time

class MyTestCase(unittest.TestCase):

        @freeze_time("2015-06-22T17:28:00Z")
        def test_thing(self):
                pass

Then
pip install freezegun

Then

sniffer

Then change a line in tests.py, the second time the tests are run you get this error:

ERROR: Failure: AttributeError ('NoneType' object has no attribute 'timedelta')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/x/test.py", line 2, in <module>
    from freezegun import freeze_time
  File "/usr/local/lib/python2.7/dist-packages/freezegun/__init__.py", line 18, in <module>
    from .api import freeze_time
  File "/usr/local/lib/python2.7/dist-packages/freezegun/api.py", line 10, in <module>
    from dateutil import parser
  File "/usr/local/lib/python2.7/dist-packages/dateutil/parser.py", line 942, in <module>
    DEFAULTPARSER = parser()
  File "/usr/local/lib/python2.7/dist-packages/dateutil/parser.py", line 341, in __init__
    self.info = info or parserinfo()
  File "/usr/local/lib/python2.7/dist-packages/dateutil/parser.py", line 259, in __init__
    self._year = time.localtime().tm_year
  File "/usr/local/lib/python2.7/dist-packages/freezegun/api.py", line 53, in __call__
    shifted_time = self.time_to_freeze() - datetime.timedelta(seconds=time.timezone)
AttributeError: 'NoneType' object has no attribute 'timedelta'

----------------------------------------------------------------------
Ran 1 test in 0.006s

FAILED (errors=1)
Failed - Back to work!
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

1 participant