(self, numpy_ref)
| 654 | |
| 655 | @pytest.mark.parametrize('numpy_ref', [True, False]) |
| 656 | def test_array_like_fromfile(self, numpy_ref): |
| 657 | self.add_method('array', self.MyArray) |
| 658 | self.add_method("fromfile", self.MyArray) |
| 659 | |
| 660 | if numpy_ref is True: |
| 661 | ref = np.array(1) |
| 662 | else: |
| 663 | ref = self.MyArray.array() |
| 664 | |
| 665 | data = np.random.random(5) |
| 666 | |
| 667 | with tempfile.TemporaryDirectory() as tmpdir: |
| 668 | fname = os.path.join(tmpdir, "testfile") |
| 669 | data.tofile(fname) |
| 670 | |
| 671 | array_like = np.fromfile(fname, like=ref) |
| 672 | if numpy_ref is True: |
| 673 | assert type(array_like) is np.ndarray |
| 674 | np_res = np.fromfile(fname, like=ref) |
| 675 | assert_equal(np_res, data) |
| 676 | assert_equal(array_like, np_res) |
| 677 | else: |
| 678 | assert type(array_like) is self.MyArray |
| 679 | assert array_like.function is self.MyArray.fromfile |
| 680 | |
| 681 | def test_exception_handling(self): |
| 682 | self.add_method('array', self.MyArray, enable_value_error=True) |
nothing calls this directly
no test coverage detected