Skip to content

Commit

Permalink
Check cvat2slowfast output
Browse files Browse the repository at this point in the history
  • Loading branch information
zhong-al committed Nov 21, 2024
1 parent 90481e5 commit 47e453a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tests/test_cvat2slowfast.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import unittest
import sys
from kabr_tools import cvat2slowfast
from tests.utils import del_dir

from tests.utils import (
del_dir,
dir_exists,
file_exists
)

def run():
cvat2slowfast.main()
Expand All @@ -29,7 +32,8 @@ def setUp(self):

def tearDown(self):
# TODO: delete outputs
del_dir(self.dataset)
#del_dir(self.dataset)
pass

def test_run(self):
# run cvat2slowfast
Expand All @@ -39,6 +43,17 @@ def test_run(self):
"--classes", self.classes]
run()

# check output dirs
self.assertTrue(dir_exists(self.dataset))
self.assertTrue(dir_exists(f"{self.dataset}/annotation"))
self.assertTrue(dir_exists(f"{self.dataset}/dataset"))
self.assertTrue(file_exists(f"{self.dataset}/annotation/classes.json"))
self.assertTrue(file_exists(f"{self.dataset}/annotation/data.csv"))

# check output files

# TODO: check output dataset

def test_parse_arg_min(self):
# parse arguments
sys.argv = [self.tool,
Expand Down
8 changes: 8 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import shutil
from pathlib import Path


def del_dir(path):
Expand All @@ -9,3 +10,10 @@ def del_dir(path):
def del_file(path):
if os.path.exists(path):
os.remove(path)

def file_exists(path):
return Path(path).is_file()


def dir_exists(path):
return Path(path).is_dir()

0 comments on commit 47e453a

Please sign in to comment.