'Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/125
Ensures that a header is not modified when setting the position of a
keyword that\'s already in its correct position.'

def test_unnecessary_move(self):

    header = fits.Header([('A', 'B'), ('B', 'C'), ('C', 'D')])
    header.set('B', before=2)
    assert (list(header) == ['A', 'B', 'C'])
    assert (not header._modified)
    header.set('B', after=0)
    assert (list(header) == ['A', 'B', 'C'])
    assert (not header._modified)
    header.set('B', before='C')
    assert (list(header) == ['A', 'B', 'C'])
    assert (not header._modified)
    header.set('B', after='A')
    assert (list(header) == ['A', 'B', 'C'])
    assert (not header._modified)
    header.set('B', before=2)
    assert (list(header) == ['A', 'B', 'C'])
    assert (not header._modified)
    header.set('C', before=123)
    assert (list(header) == ['A', 'B', 'C'])
    assert (not header._modified)
    header.set('C', after=123)
    assert (list(header) == ['A', 'B', 'C'])
    assert (not header._modified)
