chmp / ipytest

Pytest in IPython notebooks.
MIT License
314 stars 17 forks source link

warning when running tests if have "import dash" run beforehand #48

Closed yuuuxt closed 4 years ago

yuuuxt commented 4 years ago

If I run import dash before running any tests, the following warning will appear: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: dash

I assume this is enough to reproduce this issue. Feel free to contact if you need more information :)

chmp commented 4 years ago

Thanks for the report @yuuuxt . You're right, I should be able to reproduce this issue :). TBH. I'm quite swamped at the moment. I'll will not have time to look at this issues until in about two weeks.

chmp commented 4 years ago

Since ipytest rewrites the assertions of the notebook independently from pytest, you can safely disable global global assertion rewriting:

import ipytest
ipytest.autoconfig(addopts=['-q', '--assert=plain'])

This should solve the warning. Could you give it a try and see whether anything else breaks? Thanks :)

yuuuxt commented 4 years ago

I tried with a simple test case and it works fine. However, I may not encounter more complex cases.

Thanks for solving this! :)

chmp commented 4 years ago

Thanks for the feedback. Feel free to re-open if the issue pops up again.

astrojuanlu commented 2 years ago

Too bad that with this configuration the fancy coloring is gone, would be cool to find an alternative solution.

astrojuanlu commented 2 years ago

Sorry I spoke too soon: ipytest.autoconfig(addopts=['-q', '--assert=plain', '--color=yes']) works 🎉