Skip to content

Commit 0f41e17

Browse files
committed
Progress towards passing lint
1 parent 74c05e0 commit 0f41e17

File tree

2 files changed

+36
-63
lines changed

2 files changed

+36
-63
lines changed

conftest.py

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Setup for Sybil."""
22

33
import io
4-
import sys
54
from collections.abc import Generator
65
from doctest import ELLIPSIS
76
from pathlib import Path
@@ -13,11 +12,9 @@
1312
from sybil import Sybil
1413
from sybil.parsers.rest import (
1514
ClearNamespaceParser,
16-
CodeBlockParser,
1715
DocTestParser,
1816
PythonCodeBlockParser,
1917
)
20-
from sybil_extras.evaluators.shell_evaluator import ShellCommandEvaluator
2118

2219

2320
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
@@ -70,33 +67,5 @@ def mock_vws() -> Generator[None, None, None]:
7067
PythonCodeBlockParser(),
7168
],
7269
patterns=["*.rst", "*.py"],
73-
).pytest()
74-
75-
run_code_sybil = Sybil(
76-
parsers=[
77-
DocTestParser(optionflags=ELLIPSIS),
78-
PythonCodeBlockParser(),
79-
],
80-
patterns=["*.rst", "*.py"],
8170
fixtures=["make_image_file", "mock_vws"],
82-
)
83-
84-
pytest_sybil = Sybil(
85-
parsers=[
86-
CodeBlockParser(
87-
language="python",
88-
evaluator=ShellCommandEvaluator(
89-
args=[sys.executable, "-m", "pytest"],
90-
tempfile_suffixes=[".py"],
91-
pad_file=True,
92-
write_to_file=False,
93-
),
94-
),
95-
],
96-
patterns=["*.rst"],
97-
fixtures=["make_image_file"],
98-
)
99-
100-
sybils = run_code_sybil + pytest_sybil
101-
102-
pytest_collect_file = sybils.pytest()
71+
).pytest()

docs/source/index.rst

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -83,43 +83,47 @@ To write unit tests for code which uses this library, without using your Vuforia
8383
8484
.. code-block:: python
8585
86-
"""Test adding a target to VWS."""
86+
"""Add a target to VWS and then query it."""
8787
88-
import pathlib
88+
import pathlib
8989
90-
from mock_vws import MockVWS
91-
from mock_vws.database import VuforiaDatabase
90+
from mock_vws import MockVWS
91+
from mock_vws.database import VuforiaDatabase
9292
93-
from vws import VWS, CloudRecoService
93+
from vws import VWS, CloudRecoService
9494
9595
96-
def test_add_target() -> None:
97-
"""Test adding a target to VWS."""
98-
with MockVWS() as mock:
99-
database = VuforiaDatabase()
100-
mock.add_database(database=database)
101-
vws_client = VWS(
102-
server_access_key=database.server_access_key,
103-
server_secret_key=database.server_secret_key,
104-
)
105-
cloud_reco_client = CloudRecoService(
106-
client_access_key=database.client_access_key,
107-
client_secret_key=database.client_secret_key,
108-
)
96+
def test_add_target() -> None:
97+
"""Test adding a target to VWS."""
98+
with MockVWS() as mock:
99+
database = VuforiaDatabase()
100+
mock.add_database(database=database)
101+
vws_client = VWS(
102+
server_access_key=database.server_access_key,
103+
server_secret_key=database.server_secret_key,
104+
)
105+
cloud_reco_client = CloudRecoService(
106+
client_access_key=database.client_access_key,
107+
client_secret_key=database.client_secret_key,
108+
)
109+
110+
image = pathlib.Path("high_quality_image.jpg")
111+
with image.open(mode="rb") as my_image_file:
112+
target_id = vws_client.add_target(
113+
name="example_image_name",
114+
width=1,
115+
image=my_image_file,
116+
application_metadata=None,
117+
active_flag=True,
118+
)
119+
120+
vws_client.wait_for_target_processed(target_id=target_id)
121+
matching_targets = cloud_reco_client.query(image=my_image_file)
122+
123+
assert matching_targets[0].target_id == target_id
124+
109125
110-
image = pathlib.Path("high_quality_image.jpg")
111-
with image.open(mode="rb") as my_image_file:
112-
target_id = vws_client.add_target(
113-
name="example_image_name",
114-
width=1,
115-
image=my_image_file,
116-
application_metadata=None,
117-
active_flag=True,
118-
)
119-
120-
vws_client.wait_for_target_processed(target_id=target_id)
121-
matching_targets = cloud_reco_client.query(image=my_image_file)
122-
assert matching_targets[0].target_id == target_id
126+
test_add_target()
123127
124128
There are some differences between the mock and the real Vuforia.
125129
See https://vws-python-mock.readthedocs.io/en/latest/differences-to-vws.html for details.

0 commit comments

Comments
 (0)