Skip to content

Commit

Permalink
Set port during tests
Browse files Browse the repository at this point in the history
- jupyterhub#139 changes port handling, this makes tests pass.
- Sets attribute mock_port, which gets used during the port polling phase.
  • Loading branch information
rkdarst committed Jun 14, 2019
1 parent 648cf4c commit f0b091f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions batchspawner/batchspawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ def start(self):
self.ip = self.state_gethost()
while self.port == 0:
yield gen.sleep(self.startup_poll_interval)
# Test framework: For testing, mock_port is set because we
# don't actually run the single-user server yet.
if hasattr(self, 'mock_port'):
self.port = self.mock_port

if jupyterhub.version_info < (0,7):
# store on user for pre-jupyterhub-0.7:
Expand Down
2 changes: 1 addition & 1 deletion batchspawner/tests/test_spawners.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def new_spawner(db, spawner_class=BatchDummy, **kwargs):
kwargs.setdefault('server', server)
kwargs.setdefault('hub', hub)
kwargs.setdefault('user', user)
kwargs.setdefault('current_port', testport)
kwargs.setdefault('mock_port', testport)
kwargs.setdefault('INTERRUPT_TIMEOUT', 1)
kwargs.setdefault('TERM_TIMEOUT', 1)
kwargs.setdefault('KILL_TIMEOUT', 1)
Expand Down

0 comments on commit f0b091f

Please sign in to comment.