test_preview.py 988 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: utf-8 -*-
  2. from sympy.core.relational import Eq
  3. from sympy.core.symbol import Symbol
  4. from sympy.functions.elementary.piecewise import Piecewise
  5. from sympy.printing.preview import preview
  6. from io import BytesIO
  7. def test_preview():
  8. x = Symbol('x')
  9. obj = BytesIO()
  10. try:
  11. preview(x, output='png', viewer='BytesIO', outputbuffer=obj)
  12. except RuntimeError:
  13. pass # latex not installed on CI server
  14. def test_preview_unicode_symbol():
  15. # issue 9107
  16. a = Symbol('α')
  17. obj = BytesIO()
  18. try:
  19. preview(a, output='png', viewer='BytesIO', outputbuffer=obj)
  20. except RuntimeError:
  21. pass # latex not installed on CI server
  22. def test_preview_latex_construct_in_expr():
  23. # see PR 9801
  24. x = Symbol('x')
  25. pw = Piecewise((1, Eq(x, 0)), (0, True))
  26. obj = BytesIO()
  27. try:
  28. preview(pw, output='png', viewer='BytesIO', outputbuffer=obj)
  29. except RuntimeError:
  30. pass # latex not installed on CI server