from immobilus import immobilus
from immobilus.logic import _datetime_to_utc_timestamp

from datetime import datetime
from time import time


def test_time_function():

    dt = datetime(1970, 1, 1)
    assert _datetime_to_utc_timestamp(dt) == 0.0
    assert type(_datetime_to_utc_timestamp(dt)) is float
    assert time() != _datetime_to_utc_timestamp(dt)

    with immobilus(dt):
        assert time() == _datetime_to_utc_timestamp(dt)

    assert time() != _datetime_to_utc_timestamp(dt)

from immobilus import immobilus
from immobilus.logic import _datetime_to_utc_timestamp

from datetime import datetime
from time import time


def test_time_function():

    dt = datetime(1970, 1, 1)
    timestamp = _datetime_to_utc_timestamp(dt)
    assert timestamp == 0.0
    assert type(timestamp) is float
    assert time() != timestamp

    with immobilus(dt):
        assert time() == timestamp

    assert time() != timestamp

Tidy test - reuse timestamp
Tidy test - reuse timestamp

  from immobilus import immobilus
  from immobilus.logic import _datetime_to_utc_timestamp
  
  from datetime import datetime
  from time import time
  
  
  def test_time_function():
  
      dt = datetime(1970, 1, 1)
-     assert _datetime_to_utc_timestamp(dt) == 0.0
-     assert type(_datetime_to_utc_timestamp(dt)) is float
-     assert time() != _datetime_to_utc_timestamp(dt)
+     timestamp = _datetime_to_utc_timestamp(dt)
+     assert timestamp == 0.0
+     assert type(timestamp) is float
+     assert time() != timestamp
  
      with immobilus(dt):
-         assert time() == _datetime_to_utc_timestamp(dt)
+         assert time() == timestamp
  
-     assert time() != _datetime_to_utc_timestamp(dt)
+     assert time() != timestamp
  
Tidy test - reuse timestamp
## Code Before:
from immobilus import immobilus
from immobilus.logic import _datetime_to_utc_timestamp

from datetime import datetime
from time import time


def test_time_function():

    dt = datetime(1970, 1, 1)
    assert _datetime_to_utc_timestamp(dt) == 0.0
    assert type(_datetime_to_utc_timestamp(dt)) is float
    assert time() != _datetime_to_utc_timestamp(dt)

    with immobilus(dt):
        assert time() == _datetime_to_utc_timestamp(dt)

    assert time() != _datetime_to_utc_timestamp(dt)

## Instruction:
Tidy test - reuse timestamp
## Code After:
from immobilus import immobilus
from immobilus.logic import _datetime_to_utc_timestamp

from datetime import datetime
from time import time


def test_time_function():

    dt = datetime(1970, 1, 1)
    timestamp = _datetime_to_utc_timestamp(dt)
    assert timestamp == 0.0
    assert type(timestamp) is float
    assert time() != timestamp

    with immobilus(dt):
        assert time() == timestamp

    assert time() != timestamp
