8000 Update test_io.py to fix newlines · numpy/numpy@6caa73b · GitHub
[go: up one dir, main page]

Skip to content

Commit 6caa73b

Browse files
authored
Update test_io.py to fix newlines
1 parent 17a8d57 commit 6caa73b

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

numpy/lib/tests/test_io.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ def test_complex_arrays(self):
542542
re = np.pi
543543
im = np.e
544544
a[:] = re + 1.0j * im
545+
newline = os.linesep.encode()
545546

546547
# One format only
547548
c = BytesIO()
@@ -550,8 +551,10 @@ def test_complex_arrays(self):
550551
lines = c.readlines()
551552
assert_equal(
552553
lines,
553-
[b' ( +3.142e+00+ +2.718e+00j) ( +3.142e+00+ +2.718e+00j)\n',
554-
b' ( +3.142e+00+ +2.718e+00j) ( +3.142e+00+ +2.718e+00j)\n'])
554+
[b' ( +3.142e+00+ +2.718e+00j) ( +3.142e+00+ +2.718e+00j)' \
555+
+ newline,
556+
b' ( +3.142e+00+ +2.718e+00j) ( +3.142e+00+ +2.718e+00j)' \
557+
+ newline ])
555558

556559
# One format for each real and imaginary part
557560
c = BytesIO()
@@ -560,8 +563,10 @@ def test_complex_arrays(self):
560563
lines = c.readlines()
561564
assert_equal(
562565
lines,
563-
[b' +3.142e+00 +2.718e+00 +3.142e+00 +2.718e+00\n',
564-
b' +3.142e+00 +2.718e+00 +3.142e+00 +2.718e+00\n'])
566+
[b' +3.142e+00 +2.718e+00 +3.142e+00 +2.718e+00' \
567+
+ newline,
568+
b' +3.142e+00 +2.718e+00 +3.142e+00 +2.718e+00' \
569+
+ newline])
565570

566571
# One format for each complex number
567572
c = BytesIO()
@@ -570,8 +575,10 @@ def test_complex_arrays(self):
570575
lines = c.readlines()
571576
assert_equal(
572577
lines,
573-
[b'(3.142e+00+2.718e+00j) (3.142e+00+2.718e+00j)\n',
574-
b'(3.142e+00+2.718e+00j) (3.142e+00+2.718e+00j)\n'])
578+
[b'(3.142e+00+2.718e+00j) (3.142e+00+2.718e+00j)' \
579+
+ newline,
580+
b'(3.142e+00+2.718e+00j) (3.142e+00+2.718e+00j)' \
581+
+ newline])
575582

576583
def test_complex_negative_exponent(self):
577584
# Previous to 1.15, some formats generated x+-yj, gh 7895
@@ -581,14 +588,17 @@ def test_complex_negative_exponent(self):
581588
re = np.pi
582589
im = np.e
583590
a[:] = re - 1.0j * im
591+
newline = os.linesep.encode()
584592
c = BytesIO()
585593
np.savetxt(c, a, fmt='%.3e')
586594
c.seek(0)
587595
lines = c.readlines()
588596
assert_equal(
589597
lines,
590-
[b' (3.142e+00-2.718e+00j) (3.142e+00-2.718e+00j)\n',
591-
b' (3.142e+00-2.718e+00j) (3.142e+00-2.718e+00j)\n'])
598+
[b' (3.142e+00-2.718e+00j) (3.142e+00-2.718e+00j)' \
599+
+ newline,
600+
b' (3.142e+00-2.718e+00j) (3.142e+00-2.718e+00j)' \
601+
+ newline])
592602

593603

594604
def test_custom_writer(self):

0 commit comments

Comments
 (0)
0