(self)
| 438 | assert_raises(ValueError, np.savetxt, c, a, fmt=99) |
| 439 | |
| 440 | def test_header_footer(self): |
| 441 | # Test the functionality of the header and footer keyword argument. |
| 442 | |
| 443 | c = BytesIO() |
| 444 | a = np.array([(1, 2), (3, 4)], dtype=int) |
| 445 | test_header_footer = 'Test header / footer' |
| 446 | # Test the header keyword argument |
| 447 | np.savetxt(c, a, fmt='%1d', header=test_header_footer) |
| 448 | c.seek(0) |
| 449 | assert_equal(c.read(), |
| 450 | asbytes('# ' + test_header_footer + '\n1 2\n3 4\n')) |
| 451 | # Test the footer keyword argument |
| 452 | c = BytesIO() |
| 453 | np.savetxt(c, a, fmt='%1d', footer=test_header_footer) |
| 454 | c.seek(0) |
| 455 | assert_equal(c.read(), |
| 456 | asbytes('1 2\n3 4\n# ' + test_header_footer + '\n')) |
| 457 | # Test the commentstr keyword argument used on the header |
| 458 | c = BytesIO() |
| 459 | commentstr = '% ' |
| 460 | np.savetxt(c, a, fmt='%1d', |
| 461 | header=test_header_footer, comments=commentstr) |
| 462 | c.seek(0) |
| 463 | assert_equal(c.read(), |
| 464 | asbytes(commentstr + test_header_footer + '\n' + '1 2\n3 4\n')) |
| 465 | # Test the commentstr keyword argument used on the footer |
| 466 | c = BytesIO() |
| 467 | commentstr = '% ' |
| 468 | np.savetxt(c, a, fmt='%1d', |
| 469 | footer=test_header_footer, comments=commentstr) |
| 470 | c.seek(0) |
| 471 | assert_equal(c.read(), |
| 472 | asbytes('1 2\n3 4\n' + commentstr + test_header_footer + '\n')) |
| 473 | |
| 474 | def test_file_roundtrip(self): |
| 475 | with temppath() as name: |
nothing calls this directly
no test coverage detected