Skip to content

Commit ad4860b

Browse files
committed
Move tests to /tests
1 parent 9df867e commit ad4860b

2 files changed

Lines changed: 42 additions & 47 deletions

File tree

curtsies/formatstringarray.py

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import sys
2525
import logging
26-
import unittest
2726

2827
from .formatstring import fmtstr
2928
from .formatstring import normalize_slice
@@ -209,12 +208,10 @@ def __setitem__(self, slicetuple, value):
209208
]
210209
+ self.rows[rowslice.stop :]
211210
)
212-
msg = (
213-
"You are trying to fit this value {} into the region {}: {}".format(
214-
fmtstr("".join(value), bg="cyan"),
215-
fmtstr("").join(grid_value),
216-
"\n ".join(grid_fsarray[x] for x in range(len(self.rows))),
217-
)
211+
msg = "You are trying to fit this value {} into the region {}: {}".format(
212+
fmtstr("".join(value), bg="cyan"),
213+
fmtstr("").join(grid_value),
214+
"\n ".join(grid_fsarray[x] for x in range(len(self.rows))),
218215
)
219216
raise ValueError(
220217
"""Error you are trying to replace a region of {} rows by {}
@@ -300,43 +297,6 @@ def simple_format(x):
300297
return "\n".join(actualize(l) for l in x)
301298

302299

303-
class FormatStringTest(unittest.TestCase):
304-
def assertFSArraysEqual(self, a, b):
305-
# type: (FSArray, FSArray) -> None
306-
self.assertEqual(type(a), FSArray)
307-
self.assertEqual(type(b), FSArray)
308-
self.assertEqual(
309-
(a.width, b.height),
310-
(a.width, b.height),
311-
f"fsarray dimensions do not match: {a.shape} {b.shape}",
312-
)
313-
for i, (a_row, b_row) in enumerate(zip(a, b)):
314-
self.assertEqual(
315-
a_row,
316-
b_row,
317-
"FSArrays differ first on line {}:\n{}".format(i, FSArray.diff(a, b)),
318-
)
319-
320-
def assertFSArraysEqualIgnoringFormatting(self, a, b):
321-
# type: (FSArray, FSArray) -> None
322-
"""Also accepts arrays of strings"""
323-
self.assertEqual(
324-
len(a),
325-
len(b),
326-
"fsarray heights do not match: %s %s \n%s \n%s"
327-
% (len(a), len(b), simple_format(a), simple_format(b)),
328-
)
329-
for i, (a_row, b_row) in enumerate(zip(a, b)):
330-
a_row = a_row.s if isinstance(a_row, FmtStr) else a_row
331-
b_row = b_row.s if isinstance(b_row, FmtStr) else b_row
332-
self.assertEqual(
333-
a_row,
334-
b_row,
335-
"FSArrays differ first on line %s:\n%s"
336-
% (i, FSArray.diff(a, b, ignore_formatting=True)),
337-
)
338-
339-
340300
if __name__ == "__main__":
341301
a = FSArray(3, 14, bg="blue")
342302
a[0:2, 5:11] = cast(

tests/test_fmtstr.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
bold,
2121
)
2222
from curtsies.termformatconstants import FG_COLORS
23-
from curtsies.formatstringarray import fsarray, FSArray, FormatStringTest
23+
from curtsies.formatstringarray import fsarray, FSArray
2424

2525
from unittest import skip
2626

@@ -576,6 +576,43 @@ def test_oomerror(self):
576576
a[2:-2, 2:-2] = fsarray(["asdf", "zxcv"])
577577

578578

579+
class FormatStringTest(unittest.TestCase):
580+
def assertFSArraysEqual(self, a, b):
581+
# type: (FSArray, FSArray) -> None
582+
self.assertEqual(type(a), FSArray)
583+
self.assertEqual(type(b), FSArray)
584+
self.assertEqual(
585+
(a.width, b.height),
586+
(a.width, b.height),
587+
f"fsarray dimensions do not match: {a.shape} {b.shape}",
588+
)
589+
for i, (a_row, b_row) in enumerate(zip(a, b)):
590+
self.assertEqual(
591+
a_row,
592+
b_row,
593+
"FSArrays differ first on line {}:\n{}".format(i, FSArray.diff(a, b)),
594+
)
595+
596+
def assertFSArraysEqualIgnoringFormatting(self, a, b):
597+
# type: (FSArray, FSArray) -> None
598+
"""Also accepts arrays of strings"""
599+
self.assertEqual(
600+
len(a),
601+
len(b),
602+
"fsarray heights do not match: %s %s \n%s \n%s"
603+
% (len(a), len(b), simple_format(a), simple_format(b)),
604+
)
605+
for i, (a_row, b_row) in enumerate(zip(a, b)):
606+
a_row = a_row.s if isinstance(a_row, FmtStr) else a_row
607+
b_row = b_row.s if isinstance(b_row, FmtStr) else b_row
608+
self.assertEqual(
609+
a_row,
610+
b_row,
611+
"FSArrays differ first on line %s:\n%s"
612+
% (i, FSArray.diff(a, b, ignore_formatting=True)),
613+
)
614+
615+
579616
class TestFSArrayWithDiff(FormatStringTest):
580617
def test_diff_testing(self):
581618
a = fsarray(["abc", "def"])
@@ -596,6 +633,4 @@ def test_diff_testing(self):
596633

597634

598635
if __name__ == "__main__":
599-
import fmtstr.fmtstr
600-
601636
unittest.main()

0 commit comments

Comments
 (0)