Why do hooks in plugins loaded through the INI file not fire, but they do when loaded through pytest.main()
?
#11210
-
I have written a basic plugin that I wish to include via the INI file, but it doesn't seem to work. To demonstrate, take the example files below, which includes a plugin with two hooks -
It is possible to prove that the plugin is being loaded through the INI file because either -
Now using the example files with the plugin loaded through the INI file, notice how the plugin hooks are not fired ( user@computer:~/plugin-test$ python src
. [100%]
1 passed in 0.00s
user@computer:~/plugin-test$ pytest src -q
. [100%]
1 passed in 0.00s Finally, to show that the plugin works, updating the user@computer:~/plugin-test$ python src
. [100%]
2 assertions passed.
1 passed in 0.00s So my question is, how can do you get plugins to work through the INI file? It's not practical to assume that a Example files - Plugin loaded through INI file
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
To add a little more information... if the plugin was updated as follows, However, So it seems that when including a plugin through the INI file, But manually instantiating the plugin class either in the plugin file or through print('Module loaded')
class PassedAssertions:
count = 0
def __init__(self) -> None:
print('Plugin initialised')
def pytest_assertion_pass(self, *_) -> None:
self.count += 1
def pytest_terminal_summary(self, *_) -> dict:
print(f'{self.count} assertions passed.') |
Beta Was this translation helpful? Give feedback.
Registration with the plugin manager missing
See the builtin junitxml plugin for a example