Nameko test: Module already imported warning

Hello, I’m using nameko and it’s a breeze!

I have a doubt about a warning I get when I run nameko test, as the pytest warning recommends.
Every time I run it, it says:

========================================================================================= test session starts =========================================================================================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /home/checor/nameko
plugins: nameko-sqlalchemy-1.5.0, nameko-2.14.0, cov-3.0.0
collected 1 item                                                                                                                                                                               .    

========================================================================================== warnings summary ===========================================================================================
  /home/checor/.virtualenvs/nameko/lib/python3.8/site-packages/_pytest/config/ PytestAssertRewriteWarning: Module already imported so cannot be rewritten: nameko

-- Docs:

The Module already imported so cannot be rewritten: nameko worries me a little. Is it expected behaviour? My tests are running fine, but I want is there something that I missed before using nameko test.


Hey @checor,

Glad you’re enjoying Nameko.

This message is printed by pytest to warn users about the pitfalls of invoking pytest multiple times within the same process. See the note at the bottom of this page.

We are invoking pytest using the Nameko CLI, and so when the nameko module is subsequently reimported by the tests it triggers this warning. We’re not actually running multiple pytest executions in the same process so the warning doesn’t mean anything.

In a future release it’d be a good to suppress it somehow, if that’s possible.


That explains it all!
Thanks for the fast response. Now I know the tests are running flawlessly.

This warning has been suppressed in the latest releases (2.14.1 and 3.0.0-rc11)