mirror of https://github.com/nucypher/nucypher.git
Test flag to do the Character debug tracking.
parent
ab4f6a23d6
commit
531b26e5ad
|
@ -519,7 +519,7 @@ jobs:
|
|||
- run:
|
||||
name: Integration Test Suite
|
||||
command: |
|
||||
pytest $(circleci tests glob "tests/integration/**/test_*.py" | circleci tests split --split-by=timings)
|
||||
pytest --track-character-lifecycles $(circleci tests glob "tests/integration/**/test_*.py" | circleci tests split --split-by=timings)
|
||||
- capture_test_results
|
||||
|
||||
unit:
|
||||
|
@ -596,7 +596,7 @@ jobs:
|
|||
- run:
|
||||
name: Character Tests
|
||||
command: |
|
||||
pytest $(circleci tests glob "tests/acceptance/characters/**/test_*.py" "tests/learning/**/test_*.py" | circleci tests split --split-by=timings)
|
||||
pytest --track-character-lifecycles $(circleci tests glob "tests/acceptance/characters/**/test_*.py" "tests/learning/**/test_*.py" | circleci tests split --split-by=timings)
|
||||
- capture_test_results
|
||||
|
||||
cli:
|
||||
|
@ -607,7 +607,7 @@ jobs:
|
|||
- run:
|
||||
name: Nucypher CLI Tests
|
||||
command: |
|
||||
pytest $(circleci tests glob "tests/acceptance/cli/**/test_*.py" | circleci tests split --split-by=timings)
|
||||
pytest --track-character-lifecycles $(circleci tests glob "tests/acceptance/cli/**/test_*.py" | circleci tests split --split-by=timings)
|
||||
- capture_test_results
|
||||
|
||||
tests_ok:
|
||||
|
|
|
@ -172,6 +172,8 @@ class Learner:
|
|||
really_unknown_version_message = "Unable to glean address from node that perhaps purported to be version {}. We're only version {}."
|
||||
fleet_state_icon = ""
|
||||
|
||||
_DEBUG_MODE = False
|
||||
|
||||
class NotEnoughNodes(RuntimeError):
|
||||
pass
|
||||
|
||||
|
@ -252,19 +254,19 @@ class Learner:
|
|||
self._current_teacher_node = None # type: Teacher
|
||||
self._learning_task = task.LoopingCall(self.keep_learning_about_nodes)
|
||||
|
||||
# Some debugging shit. TODO: Maybe move this to a test patch?
|
||||
# Very slow, but provides useful info when trying to track down a stray Character.
|
||||
# Seems mostly useful for Bob or federated Ursulas, but perhaps useful for other Characters as well.
|
||||
if self._DEBUG_MODE:
|
||||
# Very slow, but provides useful info when trying to track down a stray Character.
|
||||
# Seems mostly useful for Bob or federated Ursulas, but perhaps useful for other Characters as well.
|
||||
|
||||
# import inspect, os
|
||||
# frames = inspect.stack(3)
|
||||
# self._learning_task = task.LoopingCall(self.keep_learning_about_nodes, learner=self, frames=frames)
|
||||
# self._init_frames = frames
|
||||
# from tests.conftest import global_mutable_where_everybody
|
||||
# test_name = os.environ["PYTEST_CURRENT_TEST"]
|
||||
# global_mutable_where_everybody[test_name].append(self)
|
||||
# self._FOR_TEST = test_name
|
||||
########################
|
||||
import inspect, os
|
||||
frames = inspect.stack(3)
|
||||
self._learning_task = task.LoopingCall(self.keep_learning_about_nodes, learner=self, frames=frames)
|
||||
self._init_frames = frames
|
||||
from tests.conftest import global_mutable_where_everybody
|
||||
test_name = os.environ["PYTEST_CURRENT_TEST"]
|
||||
global_mutable_where_everybody[test_name].append(self)
|
||||
self._FOR_TEST = test_name
|
||||
########################
|
||||
|
||||
self._learning_round = 0 # type: int
|
||||
self._rounds_without_new_nodes = 0 # type: int
|
||||
|
|
|
@ -14,6 +14,7 @@ GNU Affero General Public License for more details.
|
|||
You should have received a copy of the GNU Affero General Public License
|
||||
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
import argparse
|
||||
from collections import defaultdict
|
||||
|
||||
import pytest
|
||||
|
@ -100,6 +101,15 @@ def pytest_addoption(parser):
|
|||
default=False,
|
||||
help="run tests even if they are marked as nightly")
|
||||
|
||||
class SetLearnerDebugMode((argparse.Action)):
|
||||
def __call__(self, *args, **kwargs):
|
||||
from nucypher.network.nodes import Learner
|
||||
Learner._DEBUG_MODE = True
|
||||
parser.addoption("--track-character-lifecycles",
|
||||
action=SetLearnerDebugMode,
|
||||
default=False,
|
||||
help="Track characters in a global... mutable... where everybody...")
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
message = "{0}: mark test as {0} to run (skipped by default, use '{1}' to include these tests)"
|
||||
|
|
Loading…
Reference in New Issue