question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Already imported module

See original GitHub issue

Hey! I’m trying to migrate over my tests from nose to pytest to test my twisted application.

This site says: If a plugin is installed, pytest automatically finds and integrates it, there is no need to activate it. So according to this all I have to do is pip install pytest-twisted, but when I try running my tests I get: AttributeError: 'module' object has no attribute 'inlineCallbacks'

So on this site it says to put the following into conftest.py: pytest_plugins = "pytest_twisted" So I make conftest.py next to my testing Python file in the tests folder and get the following warning:

None
  Module already imported so can not be re-written: pytest_twisted

-- Docs: http://doc.pytest.org/en/latest/warnings.html

It seems like it auto discovers the plugin, but doesn’t update itself with inlinecallback without reimporting it? Would this be a bug, or just me not understanding something properly?

Any help is appreciated! Thank you!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nicoddemuscommented, Dec 1, 2017

Are you passing --twisted on the command line? I suggest to do that or add to the pytest.ini file:

[pytest]
twisted=1

Adding pytest_plugins to the conftest.py only works if you add it to your root conftest.py file. Anyway I suggest adding to pytest.ini as this is the simplest option IMHO.

0reactions
keller00commented, Dec 1, 2017

Okay, thanks! I’ll bug them with my question.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python: import function from an already imported module
Suppose I have a python package my_package which contains a module my_module which contains a function my_function ...
Read more >
Importing Modules — Python 3.11.1 documentation
To access the imported module on a successful load, use PyImport_ImportModule() . (Note the misnomer — this function would reload the module if...
Read more >
Import: Modules and Packages - Python Like You Mean It
Python provides a flexible framework for importing modules and specific members of a module. We have already seen in our work with NumPy...
Read more >
Importing a module runs code - Python Morsels
When Python imports a module, it runs all the code in that module. ... Now, what do you expect would happen if we...
Read more >
import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found