
import pytest

asdf = pytest.importorskip('asdf')
from asdf.tests.helpers import assert_roundtrip_tree

from astropy.time import Time, TimeDelta


@pytest.mark.parametrize('fmt', Time.FORMATS.keys())
def test_timedelta(fmt, tmpdir):

    t1 = Time(Time.now(), format=fmt)
    t2 = Time(Time.now(), format=fmt)

    td = t2 - t1
    tree = dict(timedelta=td)
    assert_roundtrip_tree(tree, tmpdir)


@pytest.mark.parametrize('scale', list(TimeDelta.SCALES) + [None])
def test_timedetal_scales(scale, tmpdir):

    tree = dict(timedelta=TimeDelta(0.125, scale=scale))
    assert_roundtrip_tree(tree, tmpdir)


import pytest

asdf = pytest.importorskip('asdf')
from asdf.tests.helpers import assert_roundtrip_tree

from astropy.time import Time, TimeDelta


@pytest.mark.parametrize('fmt', TimeDelta.FORMATS.keys())
def test_timedelta(fmt, tmpdir):

    t1 = Time(Time.now())
    t2 = Time(Time.now())

    td = TimeDelta(t2 - t1, format=fmt)
    tree = dict(timedelta=td)
    assert_roundtrip_tree(tree, tmpdir)


@pytest.mark.parametrize('scale', list(TimeDelta.SCALES) + [None])
def test_timedetal_scales(scale, tmpdir):

    tree = dict(timedelta=TimeDelta(0.125, scale=scale))
    assert_roundtrip_tree(tree, tmpdir)

Fix the ASDF test for TimeDelta formats
Fix the ASDF test for TimeDelta formats

  
  import pytest
  
  asdf = pytest.importorskip('asdf')
  from asdf.tests.helpers import assert_roundtrip_tree
  
  from astropy.time import Time, TimeDelta
  
  
- @pytest.mark.parametrize('fmt', Time.FORMATS.keys())
+ @pytest.mark.parametrize('fmt', TimeDelta.FORMATS.keys())
  def test_timedelta(fmt, tmpdir):
  
-     t1 = Time(Time.now(), format=fmt)
+     t1 = Time(Time.now())
-     t2 = Time(Time.now(), format=fmt)
+     t2 = Time(Time.now())
  
-     td = t2 - t1
+     td = TimeDelta(t2 - t1, format=fmt)
      tree = dict(timedelta=td)
      assert_roundtrip_tree(tree, tmpdir)
  
  
  @pytest.mark.parametrize('scale', list(TimeDelta.SCALES) + [None])
  def test_timedetal_scales(scale, tmpdir):
  
      tree = dict(timedelta=TimeDelta(0.125, scale=scale))
      assert_roundtrip_tree(tree, tmpdir)
  
Fix the ASDF test for TimeDelta formats
## Code Before:

import pytest

asdf = pytest.importorskip('asdf')
from asdf.tests.helpers import assert_roundtrip_tree

from astropy.time import Time, TimeDelta


@pytest.mark.parametrize('fmt', Time.FORMATS.keys())
def test_timedelta(fmt, tmpdir):

    t1 = Time(Time.now(), format=fmt)
    t2 = Time(Time.now(), format=fmt)

    td = t2 - t1
    tree = dict(timedelta=td)
    assert_roundtrip_tree(tree, tmpdir)


@pytest.mark.parametrize('scale', list(TimeDelta.SCALES) + [None])
def test_timedetal_scales(scale, tmpdir):

    tree = dict(timedelta=TimeDelta(0.125, scale=scale))
    assert_roundtrip_tree(tree, tmpdir)

## Instruction:
Fix the ASDF test for TimeDelta formats
## Code After:

import pytest

asdf = pytest.importorskip('asdf')
from asdf.tests.helpers import assert_roundtrip_tree

from astropy.time import Time, TimeDelta


@pytest.mark.parametrize('fmt', TimeDelta.FORMATS.keys())
def test_timedelta(fmt, tmpdir):

    t1 = Time(Time.now())
    t2 = Time(Time.now())

    td = TimeDelta(t2 - t1, format=fmt)
    tree = dict(timedelta=td)
    assert_roundtrip_tree(tree, tmpdir)


@pytest.mark.parametrize('scale', list(TimeDelta.SCALES) + [None])
def test_timedetal_scales(scale, tmpdir):

    tree = dict(timedelta=TimeDelta(0.125, scale=scale))
    assert_roundtrip_tree(tree, tmpdir)
