def test_utf8(self): expected = '\u2122 \u2122 \u2122\n\u2122 \u2122 \u2122\n\u2122' text = '\u2122 \u2122 \u2122 \u2122 \u2122 \u2122 \u2122' liner.set_clipboard_data(text) liner.main(['-c', '-l', '5']) actual = liner.get_clipboard_data() self.assertEqual(expected, actual)
def test_trailing_whitespace(self): """ trailing whitespace is stripped """ expected = '\n\nabc\n\n' text = ' \n\t\t\nabc \n \n' liner.set_clipboard_data(text) liner.main(['-c']) actual = liner.get_clipboard_data() self.assertEqual(expected, actual)
def test_line_length_less_than_one_and_multiple_lines(self): """ lines are joined """ expected = ('Vivamus sagittis lacus vel augue laoreet rutrum ' 'faucibus dolor auctor. Nullam quis risus eget urna ' 'mollis ornare vel eu leo.') text = ('Vivamus sagittis lacus vel augue \nlaoreet rutrum ' 'faucibus dolor\nauctor. Nullam quis risus eget \n' 'urna mollis ornare\nvel eu leo.') liner.set_clipboard_data(text) liner.main(['-c', '-l', 0]) actual = liner.get_clipboard_data() self.assertEqual(expected, actual)
def get_expected_and_actual(testfile, line_length=None): testfile = TEST_FILES_DIR + testfile if line_length: liner.main(['-f', testfile, '-l', line_length]) else: liner.main(['-f', testfile]) expected = liner.read_file(testfile + EXPECTED_SUFFIX) actual = liner.read_file(testfile + liner.LINED_SUFFIX) return expected, actual
def get_expected_and_actual_pipe(testfile, line_length=None): testfile = TEST_FILES_DIR + testfile sys.stdin = open(testfile, 'r') sys.stdout = open(testfile + liner.LINED_SUFFIX, 'w') if line_length: liner.main(['-l', line_length]) else: liner.main([]) expected = liner.read_file(testfile + '_lined_expected') actual = liner.read_file(testfile + liner.LINED_SUFFIX) return expected, actual
def test_line_length_as_string(self): liner.set_clipboard_data('Lorem ipsum dolor sit amet') liner.main(['-c', '-l', '017']) expected = 'Lorem ipsum dolor\nsit amet' actual = liner.get_clipboard_data() self.assertEqual(expected, actual)
def test_line_length_less_than_one_and_newline(self): expected = 'Lorem ipsum dolor sit amet\n' liner.set_clipboard_data(expected) liner.main(['-c', '-l', '-1']) actual = liner.get_clipboard_data() self.assertEqual(expected, actual)