Skip to content

test_that_from_datetime_rejets_naive_datetimes doesn't raise although it should #31

@charmoniumQ

Description

@charmoniumQ
Test output
======================================================================
FAIL: utcdatetime.tests.test_from_datetime.test_that_from_datetime_rejets_naive_datetimes
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/nix/store/h8h15jlcqxgxp6jv3r5m2kywy1l56b9y-python3.10-nose-1.3.7/lib/python3.10/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/build/utcdatetime-0.0.7/utcdatetime/tests/test_from_datetime.py", line 28, in test_that_from_datetime_rejets_naive_datetimes
    assert_raises(ValueError, lambda: utcdatetime.from_datetime(
AssertionError: ValueError not raised by <lambda>

----------------------------------------------------------------------
Ran 120 tests in 0.073s

FAILED (failures=1)
Test failed: <unittest.runner.TextTestResult run=120 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=120 errors=0 failures=1>

utcdatetime.from_datetime is defined as

    @classmethod
    def from_datetime(cls, dt):
        dt_utc = dt.astimezone(UTC)
        ...

According to Python documentation

Changed in version 3.6: The astimezone() method can now be called on naive instances that are presumed to represent system local time.

Presumably this would raise an ValueError before 3.6, but it does not in any newer Pythons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions