treebeardtech / nbmake

📝 Pytest plugin for testing notebooks
https://pypi.org/project/nbmake/
Apache License 2.0
189 stars 18 forks source link

UnicodeEncodeError on Windows raised in pytest_terminal_summary() #121

Closed lbianchi-lbl closed 9 months ago

lbianchi-lbl commented 9 months ago

Describe the bug

Complete stack trace

 C:\Miniconda\envs\watertap-dev\lib\site-packages\coverage\control.py:887: CoverageWarning: No data was collected. (no-data-collected)
  self._warn("No data was collected.", slug="no-data-collected")
Traceback (most recent call last):
  File "C:\Miniconda\envs\watertap-dev\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Miniconda\envs\watertap-dev\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Miniconda\envs\watertap-dev\Scripts\pytest.exe\__main__.py", line 7, in <module>
    sys.exit(console_main())
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\_pytest\config\__init__.py", line 198, in console_main
    code = main()
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\_pytest\config\__init__.py", line 175, in main
    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_hooks.py", line 501, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\_pytest\main.py", line 320, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\_pytest\main.py", line 273, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_hooks.py", line 501, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_callers.py", line 138, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_callers.py", line 121, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\_pytest\logging.py", line 861, in pytest_sessionfinish
    return (yield)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_callers.py", line 123, in _multicall
    teardown.send(result)  # type: ignore[union-attr]
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\_pytest\terminal.py", line 864, in pytest_sessionfinish
    self.config.hook.pytest_terminal_summary(
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_hooks.py", line 501, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_callers.py", line 138, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_callers.py", line 121, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\_pytest\terminal.py", line 886, in pytest_terminal_summary
    return (yield)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_callers.py", line 121, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\_pytest\warnings.py", line 129, in pytest_terminal_summary
    return (yield)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\pluggy\_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
  File "C:\Miniconda\envs\watertap-dev\lib\site-packages\nbmake\pytest_plugin.py", line 77, in pytest_terminal_summary
    print(f"\n\U0001f4dd nbmake support is available in discord: {discord}\n")
  File "C:\Miniconda\envs\watertap-dev\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f4dd' in position 2: character maps to <undefined>

To Reproduce

Expected behavior

Desktop (please complete the following information):

  Package                       Version         Editable project location
  ----------------------------- --------------- -------------------------
  alabaster                     0.7.13
  anyio                         4.3.0
  argon2-cffi                   23.1.0
  argon2-cffi-bindings          21.2.0
  arrow                         1.3.0
  astroid                       2.15.8
  asttokens                     2.4.1
  async-lru                     2.0.4
  attrs                         23.2.0
  Babel                         2.14.0
  backcall                      0.2.0
  beautifulsoup4                4.12.3
  black                         22.3.0
  bleach                        6.1.0
  certifi                       2024.2.2
  cffi                          1.16.0
  cfgv                          3.4.0
  charset-normalizer            3.3.2
  click                         8.1.7
  colorama                      0.4.6
  comm                          0.2.1
  contourpy                     1.1.1
  coverage                      7.4.3
  cryptography                  42.0.5
  cycler                        0.12.1
  dataclasses-json              0.5.14
  debugpy                       1.8.1
  decorator                     5.1.1
  defusedxml                    0.7.1
  dill                          0.3.8
  distlib                       0.3.8
  dnspython                     2.6.1
  docutils                      0.20.1
  exceptiongroup                1.2.0
  executing                     2.0.1
  fastjsonschema                2.19.1
  filelock                      3.13.1
  fonttools                     4.49.0
  fqdn                          1.5.1
  h11                           0.14.0
  h5py                          3.10.0
  htmlmin                       0.1.12
  httpcore                      1.0.4
  httpx                         0.27.0
  idaes-pse                     2.3.0
  identify                      2.5.35
  idna                          3.6
  imagesize                     1.4.1
  importlib-metadata            7.0.1
  importlib_resources           6.1.2
  iniconfig                     2.0.0
  ipykernel                     6.29.3
  ipython                       8.12.3
  ipywidgets                    8.1.2
  isoduration                   20.11.0
  isort                         5.13.2
  jedi                          0.19.1
  Jinja2                        3.0.3
  json-schema-for-humans        0.47
  json5                         0.9.20
  jsonpointer                   2.4
  jsonschema                    4.21.1
  jsonschema-specifications     2023.12.1
  jupyter                       1.0.0
  jupyter_client                8.6.0
  jupyter-console               6.6.3
  jupyter_core                  5.7.1
  jupyter-events                0.9.0
  jupyter-lsp                   2.2.3
  jupyter_server                2.13.0
  jupyter_server_terminals      0.5.2
  jupyterlab                    4.1.2
  jupyterlab_pygments           0.3.0
  jupyterlab_server             2.25.3
  jupyterlab_widgets            3.0.10
  kiwisolver                    1.4.5
  lazy-object-proxy             1.10.0
  linkify-it-py                 2.0.3
  markdown2                     2.4.13
  MarkupSafe                    2.1.5
  marshmallow                   3.21.0
  matplotlib                    3.7.5
  matplotlib-inline             0.1.6
  mccabe                        0.7.0
  mistune                       3.0.2
  mongomock                     4.1.2
  mpmath                        1.3.0
  mypy-extensions               1.0.0
  nbclient                      0.6.8
  nbconvert                     7.16.1
  nbformat                      5.9.2
  nbmake                        1.5.1
  nbsphinx                      0.9.3
  nest-asyncio                  1.6.0
  networkx                      3.1
  nodeenv                       1.8.0
  notebook                      7.1.1
  notebook_shim                 0.2.4
  numpy                         1.24.4
  overrides                     7.7.0
  packaging                     23.2
  pandas                        2.0.3
  pandocfilters                 1.5.1
  parso                         0.8.3
  pathspec                      0.12.1
  pickleshare                   0.7.5
  pillow                        10.2.0
  Pint                          0.21.1
  pip                           23.3.1
  pkgutil_resolve_name          1.3.10
  platformdirs                  4.2.0
  pluggy                        1.4.0
  ply                           3.11
  pre-commit                    3.5.0
  prometheus_client             0.20.0
  prompt-toolkit                3.0.43
  psutil                        5.9.8
  pure-eval                     0.2.2
  pycparser                     2.21
  pydantic                      1.10.14
  Pygments                      2.17.2
  pylint                        2.17.7
  pymongo                       4.6.2
  Pyomo                         6.7.1
  pyparsing                     3.1.1
  pytest                        8.0.2
  pytest-cov                    4.1.0
  python-dateutil               2.9.0.post0
  python-json-logger            2.0.7
  pytz                          2024.1
  pywin32                       306
  pywinpty                      2.0.13
  PyYAML                        6.0.1
  pyzmq                         25.1.2
  qtconsole                     5.5.1
  QtPy                          2.4.1
  referencing                   0.33.0
  requests                      2.31.0
  rfc3339-validator             0.1.4
  rfc3986-validator             0.1.1
  rpds-py                       0.18.0
  scipy                         1.10.1
  Send2Trash                    1.8.2
  sentinels                     1.0.0
  setuptools                    68.2.2
  six                           1.16.0
  sniffio                       1.3.1
  snowballstemmer               2.2.0
  soupsieve                     2.5
  Sphinx                        7.1.2
  sphinx-rtd-theme              2.0.0
  sphinxcontrib-applehelp       1.0.4
  sphinxcontrib-devhelp         1.0.2
  sphinxcontrib-htmlhelp        2.0.1
  sphinxcontrib-jquery          4.1
  sphinxcontrib-jsmath          1.0.1
  sphinxcontrib-qthelp          1.0.3
  sphinxcontrib-serializinghtml 1.1.5
  stack-data                    0.6.3
  sympy                         1.12
  terminado                     0.18.0
  tinycss2                      1.2.1
  tomli                         2.0.1
  tomlkit                       0.12.4
  tornado                       6.4
  traitlets                     5.14.1
  types-python-dateutil         2.8.19.20240106
  typing_extensions             4.10.0
  typing-inspect                0.9.0
  tzdata                        2024.1
  uc-micro-py                   1.0.3
  uri-template                  1.3.0
  urllib3                       1.26.18
  virtualenv                    20.25.1
  watertap                      0.12.dev0       D:\a\watertap\watertap
  wcwidth                       0.2.13
  webcolors                     1.13
  webencodings                  0.5.1
  websocket-client              1.7.0
  wheel                         0.41.2
  widgetsnbextension            4.0.10
  wrapt                         1.16.0
  zipp                          3.17.0
alex-treebeard commented 9 months ago

thanks for reporting this -- sadly I gave up testing on windows a while ago due to lack of windows test coverage on our jupyter dependencies making it an uphill battle

Regardless, it makes sense fixing windows issues. Fixed in 1.5.2