Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
recsystems
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Renewal
recsystems
Commits
dea7d6cd
Commit
dea7d6cd
authored
4 years ago
by
E. Madison Bray
Browse files
Options
Downloads
Patches
Plain Diff
[testing] rename these functions so that pytest doesn't try to collect them as a test
parent
cafd7287
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#1241
passed
4 years ago
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
renewal_recsystem/utils/testing/functional.py
+2
-2
2 additions, 2 deletions
renewal_recsystem/utils/testing/functional.py
renewal_recsystem/utils/testing/server.py
+9
-9
9 additions, 9 deletions
renewal_recsystem/utils/testing/server.py
with
11 additions
and
11 deletions
renewal_recsystem/utils/testing/functional.py
+
2
−
2
View file @
dea7d6cd
...
...
@@ -13,7 +13,7 @@ import tempfile
import
pytest
from
.
import
get_free_port_safe
,
generate_articles
,
random_user_id
,
retry
from
.server
import
test
_server_thread
from
.server
import
dummy
_server_thread
class
RecsystemFunctionalTest
(
metaclass
=
abc
.
ABCMeta
):
...
...
@@ -84,7 +84,7 @@ class RecsystemFunctionalTest(metaclass=abc.ABCMeta):
# start up the test server
with
get_free_port_safe
()
as
port
:
cls
.
server
=
test
_server_thread
(
port
)
cls
.
server
=
dummy
_server_thread
(
port
)
cls
.
server
.
wait
()
# start up the recsystem using the given port
...
...
This diff is collapsed.
Click to expand it.
renewal_recsystem/utils/testing/server.py
+
9
−
9
View file @
dea7d6cd
...
...
@@ -140,7 +140,7 @@ def _make_server_task(port, articles=None, get_rpc_call=None,
return
task
def
test
_server
(
port
=
None
,
articles
=
None
,
quiet
=
False
,
**
kwargs
):
def
dummy
_server
(
port
=
None
,
articles
=
None
,
quiet
=
False
,
**
kwargs
):
loop
=
asyncio
.
get_event_loop
()
try
:
server_task
=
_make_server_task
(
port
,
articles
,
quiet
=
quiet
,
**
kwargs
)
...
...
@@ -168,10 +168,10 @@ class ServerThread(threading.Thread):
self
.
_rpc_call_queue
=
asyncio
.
Queue
()
self
.
_rpc_result_queue
=
asyncio
.
Queue
()
self
.
_stop_event
=
asyncio
.
Event
()
test
_server
(
get_rpc_call
=
self
.
_rpc_call_queue
.
get
,
put_rpc_result
=
self
.
_rpc_result_queue
.
put
,
shutdown_trigger
=
self
.
_stop_event
.
wait
,
**
self
.
_server_kwargs
)
dummy
_server
(
get_rpc_call
=
self
.
_rpc_call_queue
.
get
,
put_rpc_result
=
self
.
_rpc_result_queue
.
put
,
shutdown_trigger
=
self
.
_stop_event
.
wait
,
**
self
.
_server_kwargs
)
def
wait
(
self
):
"""
Wait for the server port to be bound.
"""
...
...
@@ -219,9 +219,9 @@ class ServerThread(threading.Thread):
return
def
test
_server_thread
(
port
=
None
,
articles
=
None
,
quiet
=
True
,
**
kwargs
):
def
dummy
_server_thread
(
port
=
None
,
articles
=
None
,
quiet
=
True
,
**
kwargs
):
"""
Starts `
test
_server` but in its own thread.
Starts `
dummy
_server` but in its own thread.
Returns a `ServerThread` object which has `ServerThread.request` and
`ServerThread.notify` methods which send JSON-RPC calls to the connected
...
...
@@ -233,9 +233,9 @@ def test_server_thread(port=None, articles=None, quiet=True, **kwargs):
First start up the server thread:
>>>
from
renewal_recsystem.utils.testing
import
get_free_port_safe
>>>
from
renewal_recsystem.utils.testing.server
import
test
_server_thread
>>>
from
renewal_recsystem.utils.testing.server
import
dummy
_server_thread
>>>
with
get_free_port_safe
()
as
port
:
...
server_thread
=
test
_server_thread
(
port
=
port
)
...
server_thread
=
dummy
_server_thread
(
port
=
port
)
...
server_thread
.
wait
()
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment