Skip to content

Commit f5c8d16

Browse files
committed
2 parents 6f8f733 + 10eb1c9 commit f5c8d16

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

.vscode/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
22
"python.formatting.provider": "yapf",
33
"python.linting.pylintPath": "~/miniconda3/bin/pylint",
4-
"python.linting.pylintEnabled": true
4+
"python.linting.pylintEnabled": true,
5+
"python.testing.pytestArgs": [
6+
"tests"
7+
],
8+
"python.testing.unittestEnabled": false,
9+
"python.testing.nosetestsEnabled": false,
10+
"python.testing.pytestEnabled": true
511
}

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
addopts=-n8

tests/test_annotation_adding.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,16 @@ def test_add_bbox_noinit(tmpdir):
131131
assert len(annotations_new["instances"]) == 2
132132
export = sa.prepare_export(project, include_fuse=True)
133133
sa.download_export(project, export, tmpdir)
134-
assert len(list(Path(tmpdir).rglob("*.*"))) == 4
134+
135+
non_empty_annotations = 0
136+
json_files = tmpdir.glob("*.json")
137+
for json_file in json_files:
138+
json_ann = json.load(open(json_file))
139+
if "instances" in json_ann and len(json_ann["instances"]) > 0:
140+
non_empty_annotations += 1
141+
assert len(json_ann["instances"]) == 2
142+
143+
assert non_empty_annotations == 1
135144

136145

137146
def test_add_bbox_json(tmpdir):
@@ -169,5 +178,4 @@ def test_add_bbox_json(tmpdir):
169178

170179
assert len(annotations_new["instances"]
171180
) == len(annotations["instances"]) + 7
172-
assert len(annotations_new["comments"]
173-
) == len(annotations["comments"]) + 1
181+
assert len(annotations_new["comments"]) == len(annotations["comments"]) + 1

tests/test_recursive_folder.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
import json
12
from pathlib import Path
23
import time
34

45
import superannotate as sa
56

6-
sa.init(Path.home() / ".superannotate" / "config.json")
7-
87
TEMP_PROJECT_NAME = "test_recursive"
98

109

@@ -40,7 +39,14 @@ def test_nonrecursive_annotations_folder(tmpdir):
4039
time.sleep(1)
4140
sa.download_export(project, export, tmpdir)
4241

43-
assert len(list(tmpdir.glob("*.json"))) == 1
42+
non_empty_annotations = 0
43+
json_files = tmpdir.glob("*.json")
44+
for json_file in json_files:
45+
json_ann = json.load(open(json_file))
46+
if "instances" in json_ann and len(json_ann["instances"]) > 0:
47+
non_empty_annotations += 1
48+
49+
assert non_empty_annotations == 1
4450

4551

4652
def test_recursive_annotations_folder(tmpdir):
@@ -223,7 +229,14 @@ def test_annotations_nonrecursive_s3_folder(tmpdir):
223229
time.sleep(1)
224230
sa.download_export(project, export, tmpdir)
225231

226-
assert len(list(tmpdir.glob("*.json"))) == 1
232+
non_empty_annotations = 0
233+
json_files = tmpdir.glob("*.json")
234+
for json_file in json_files:
235+
json_ann = json.load(open(json_file))
236+
if "instances" in json_ann and len(json_ann["instances"]) > 0:
237+
non_empty_annotations += 1
238+
239+
assert non_empty_annotations == 1
227240

228241

229242
def test_preannotations_recursive_s3_folder(tmpdir):

0 commit comments

Comments
 (0)