Created
August 26, 2014 07:49
-
-
Save damnit/1f13a5eb34ef7e71b38f to your computer and use it in GitHub Desktop.
test trac components with pytest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ This module shows how to create Components. """ | |
| from trac.core import Component | |
| import pytest | |
| @pytest.fixture | |
| def component_manager(): | |
| from trac.core import ComponentManager | |
| return ComponentManager() | |
| class TestComponent(Component): | |
| """ the component itself. """ | |
| def __init__(self): | |
| Component.__init__(self) | |
| def test_register_component(component_manager): | |
| TestComponent(component_manager) | |
| assert len(component_manager.components) == 1 | |
| def test_disable_component(component_manager): | |
| TestComponent(component_manager) | |
| component_manager.disable_component(TestComponent) | |
| assert component_manager.components.values()[0] == None | |
| def test_reenable_component(component_manager): | |
| TestComponent(component_manager) | |
| assert len(component_manager.components) == 1 | |
| component_manager.disable_component(TestComponent) | |
| assert component_manager.components.values()[0] == None | |
| TestComponent(component_manager) | |
| assert component_manager.components.values()[0] != None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment