test_verbose.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. """
  2. Tests that work on both the Python and C engines but do not have a
  3. specific classification into the other test modules.
  4. """
  5. from io import StringIO
  6. import pytest
  7. pytestmark = pytest.mark.usefixtures("pyarrow_skip")
  8. def test_verbose_read(all_parsers, capsys):
  9. parser = all_parsers
  10. data = """a,b,c,d
  11. one,1,2,3
  12. one,1,2,3
  13. ,1,2,3
  14. one,1,2,3
  15. ,1,2,3
  16. ,1,2,3
  17. one,1,2,3
  18. two,1,2,3"""
  19. # Engines are verbose in different ways.
  20. parser.read_csv(StringIO(data), verbose=True)
  21. captured = capsys.readouterr()
  22. if parser.engine == "c":
  23. assert "Tokenization took:" in captured.out
  24. assert "Parser memory cleanup took:" in captured.out
  25. else: # Python engine
  26. assert captured.out == "Filled 3 NA values in column a\n"
  27. def test_verbose_read2(all_parsers, capsys):
  28. parser = all_parsers
  29. data = """a,b,c,d
  30. one,1,2,3
  31. two,1,2,3
  32. three,1,2,3
  33. four,1,2,3
  34. five,1,2,3
  35. ,1,2,3
  36. seven,1,2,3
  37. eight,1,2,3"""
  38. parser.read_csv(StringIO(data), verbose=True, index_col=0)
  39. captured = capsys.readouterr()
  40. # Engines are verbose in different ways.
  41. if parser.engine == "c":
  42. assert "Tokenization took:" in captured.out
  43. assert "Parser memory cleanup took:" in captured.out
  44. else: # Python engine
  45. assert captured.out == "Filled 1 NA values in column a\n"