1# Licensed under a 3-clause BSD style license - see PYFITS.rst
2
3import numpy as np
4
5from astropy.io import fits
6from . import FitsTestCase
7
8
9class TestDivisionFunctions(FitsTestCase):
10    """Test code units that rely on correct integer division."""
11
12    def test_rec_from_string(self):
13        with fits.open(self.data('tb.fits')) as t1:
14            s = t1[1].data.tobytes()
15        np.rec.array(
16            s,
17            dtype=np.dtype([('c1', '>i4'), ('c2', '|S3'),
18                            ('c3', '>f4'), ('c4', '|i1')]),
19            shape=len(s) // 12)
20
21    def test_card_with_continue(self):
22        h = fits.PrimaryHDU()
23        h.header['abc'] = 'abcdefg' * 20
24
25    def test_valid_hdu_size(self):
26        with fits.open(self.data('tb.fits')) as t1:
27            assert type(t1[1].size) is type(1)  # noqa
28
29    def test_hdu_get_size(self):
30        with fits.open(self.data('tb.fits')) as _:
31            pass
32
33    def test_section(self, capsys):
34        # section testing
35        with fits.open(self.data('arange.fits')) as fs:
36            assert np.all(fs[0].section[3, 2, 5] == np.array([357]))
37