-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add log messages to containers logs on test start,end
- Loading branch information
Shay Arbov
committed
Oct 9, 2017
1 parent
dd0d370
commit 7dd23fb
Showing
4 changed files
with
60 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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 file contains 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 file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,32 @@ | ||
"""utilized by in pytest configuration.""" | ||
import pytest | ||
|
||
from docker_test_tools.environment import EnvironmentController | ||
|
||
controller = EnvironmentController.from_file(config_path='tests/integration/pytest.cfg') | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def global_setup_teardown(): | ||
"""This function will be executed once per testing session.""" | ||
def pytest_configure(config): | ||
"""Run prior to any test - setup the environment.""" | ||
controller.setup() | ||
yield | ||
|
||
|
||
def pytest_unconfigure(config): | ||
"""Run post all tests - tear down the environment.""" | ||
controller.teardown() | ||
|
||
|
||
def pytest_runtest_setup(item): | ||
"""Assign the controller as a test class member.""" | ||
"""Run on test start. | ||
- Assign the controller object to the test. | ||
- Write a test started log message to the main log file. | ||
""" | ||
item.parent.obj.controller = controller | ||
controller.write_common_log_message("TEST STARTED: {test_id}".format(test_id=item.nodeid)) | ||
|
||
|
||
def pytest_runtest_teardown(item): | ||
""""Run on test stop. | ||
- Write a test ended log message to the main log file. | ||
""" | ||
controller.write_common_log_message("TEST ENDED: {test_id}".format(test_id=item.nodeid)) |