def join_columns(test_lines): """ Test that join() and columns() can be used to write data and read it back. """ assume( all( all("\n" not in col and "\t" not in col and " " not in col for col in line) for line in test_lines)) assume([] not in test_lines) result_tab = each(*test_lines) >> join("\t") >> column(0) >> collect() result_space = ( each(*test_lines) >> join(" ") >> column(0, sep=" ") >> collect()) first_columns = [line[0] for line in test_lines] assert result_tab == first_columns assert result_space == first_columns
def test_join_accepts_floats(self): """ Test that we can pass floating point numbers to `join()`. """ value = (each(["hello", 1.3125, "bye"]) >> join(" ") >> collect())[0] self.assertEqual(value, "hello 1.3125 bye")
def test_join_accepts_ints(self): """ Test that we can pass integers to `join()`. """ value = (each(["hello", 1, "bye"]) >> join(" ") >> collect())[0] self.assertEqual(value, "hello 1 bye")