Reputation: 1007
I'm just starting out with pytest
and pytest_mysql
and have the following code:
import pytest
from pytest_mysql import factories
if __name__ == "__main__":
pytest.main([r'test.py', '-v'])
testdb = factories.mysql('testdb')
This generates a warning:
PytestAssertRewriteWarning: Module already imported so cannot be rewritten: pytest_mysql
Upvotes: 2
Views: 2578
Reputation: 69
import pytest
if __name__=='__main__': #Note 1
pytest.main()
#
#Your code goes here
#
from pytest_mysql import factories
testdb = factories.mysql('testdb')
So try running pytest.main() before you import anything else..
Note 1
That's not the usual way you call __name__=='__main__'
, but as it works i buy it!
Upvotes: 2