Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions python_files/tests/unittestadapter/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import pytest

from unittestadapter.discovery import discover_tests
from unittestadapter.pvsc_utils import TestNodeTypeEnum, parse_unittest_args
from unittestadapter.pvsc_utils import TestNodeTypeEnum as NodeTypeEnum
from unittestadapter.pvsc_utils import parse_unittest_args

script_dir = pathlib.Path(__file__).parent.parent
sys.path.append(os.fspath(script_dir))
Expand Down Expand Up @@ -85,30 +86,30 @@ def test_simple_discovery() -> None:

expected = {
"path": start_dir,
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"name": ".data",
"children": [
{
"name": "discovery_simple.py",
"type_": TestNodeTypeEnum.file,
"type_": NodeTypeEnum.file,
"path": file_path,
"children": [
{
"name": "DiscoverySimple",
"path": file_path,
"type_": TestNodeTypeEnum.class_,
"type_": NodeTypeEnum.class_,
"children": [
{
"name": "test_one",
"path": file_path,
"type_": TestNodeTypeEnum.test,
"type_": NodeTypeEnum.test,
"lineno": "14",
"id_": file_path + "\\" + "DiscoverySimple" + "\\" + "test_one",
},
{
"name": "test_two",
"path": file_path,
"type_": TestNodeTypeEnum.test,
"type_": NodeTypeEnum.test,
"lineno": "17",
"id_": file_path + "\\" + "DiscoverySimple" + "\\" + "test_two",
},
Expand Down Expand Up @@ -137,30 +138,30 @@ def test_simple_discovery_with_top_dir_calculated() -> None:

expected = {
"path": os.fsdecode(pathlib.PurePath(TEST_DATA_PATH)),
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"name": ".data",
"children": [
{
"name": "discovery_simple.py",
"type_": TestNodeTypeEnum.file,
"type_": NodeTypeEnum.file,
"path": file_path,
"children": [
{
"name": "DiscoverySimple",
"path": file_path,
"type_": TestNodeTypeEnum.class_,
"type_": NodeTypeEnum.class_,
"children": [
{
"name": "test_one",
"path": file_path,
"type_": TestNodeTypeEnum.test,
"type_": NodeTypeEnum.test,
"lineno": "14",
"id_": file_path + "\\" + "DiscoverySimple" + "\\" + "test_one",
},
{
"name": "test_two",
"path": file_path,
"type_": TestNodeTypeEnum.test,
"type_": NodeTypeEnum.test,
"lineno": "17",
"id_": file_path + "\\" + "DiscoverySimple" + "\\" + "test_two",
},
Expand Down Expand Up @@ -206,30 +207,30 @@ def test_error_discovery() -> None:

expected = {
"path": start_dir,
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"name": "discovery_error",
"children": [
{
"name": "file_two.py",
"type_": TestNodeTypeEnum.file,
"type_": NodeTypeEnum.file,
"path": file_path,
"children": [
{
"name": "DiscoveryErrorTwo",
"path": file_path,
"type_": TestNodeTypeEnum.class_,
"type_": NodeTypeEnum.class_,
"children": [
{
"name": "test_one",
"path": file_path,
"type_": TestNodeTypeEnum.test,
"type_": NodeTypeEnum.test,
"lineno": "14",
"id_": file_path + "\\" + "DiscoveryErrorTwo" + "\\" + "test_one",
},
{
"name": "test_two",
"path": file_path,
"type_": TestNodeTypeEnum.test,
"type_": NodeTypeEnum.test,
"lineno": "17",
"id_": file_path + "\\" + "DiscoveryErrorTwo" + "\\" + "test_two",
},
Expand Down
56 changes: 28 additions & 28 deletions python_files/tests/unittestadapter/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import pytest

from unittestadapter.pvsc_utils import TestNode as Node
from unittestadapter.pvsc_utils import TestNodeTypeEnum as NodeTypeEnum
from unittestadapter.pvsc_utils import (
TestNode,
TestNodeTypeEnum,
build_test_tree,
get_child_node,
get_test_case,
Expand Down Expand Up @@ -65,27 +65,27 @@ def test_simple_test_cases(directory, pattern, expected) -> None:

def test_get_existing_child_node() -> None:
"""The get_child_node fuction should return the child node of a test tree if it exists."""
tree: TestNode = {
tree: Node = {
"name": "root",
"path": "foo",
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"children": [
{
"name": "childOne",
"path": "child/one",
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"children": [
{
"name": "nestedOne",
"path": "nested/one",
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"children": [],
"id_": "nested/one",
},
{
"name": "nestedTwo",
"path": "nested/two",
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"children": [],
"id_": "nested/two",
},
Expand All @@ -95,15 +95,15 @@ def test_get_existing_child_node() -> None:
{
"name": "childTwo",
"path": "child/two",
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"children": [],
"id_": "child/two",
},
],
"id_": "foo",
}

get_child_node("childTwo", "child/two", TestNodeTypeEnum.folder, tree)
get_child_node("childTwo", "child/two", NodeTypeEnum.folder, tree)
tree_copy = tree.copy()

# Check that the tree didn't get mutated by get_child_node.
Expand All @@ -112,27 +112,27 @@ def test_get_existing_child_node() -> None:

def test_no_existing_child_node() -> None:
"""The get_child_node fuction should add a child node to a test tree and return it if it does not exist."""
tree: TestNode = {
tree: Node = {
"name": "root",
"path": "foo",
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"children": [
{
"name": "childOne",
"path": "child/one",
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"children": [
{
"name": "nestedOne",
"path": "nested/one",
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"children": [],
"id_": "nested/one",
},
{
"name": "nestedTwo",
"path": "nested/two",
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"children": [],
"id_": "nested/two",
},
Expand All @@ -142,7 +142,7 @@ def test_no_existing_child_node() -> None:
{
"name": "childTwo",
"path": "child/two",
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"children": [],
"id_": "child/two",
},
Expand All @@ -154,7 +154,7 @@ def test_no_existing_child_node() -> None:
tree_before = tree.copy()
tree_before["children"] = tree["children"][:]

get_child_node("childThree", "child/three", TestNodeTypeEnum.folder, tree)
get_child_node("childThree", "child/three", NodeTypeEnum.folder, tree)

tree_after = tree.copy()
tree_after["children"] = tree_after["children"][:-1]
Expand All @@ -174,33 +174,33 @@ def test_build_simple_tree() -> None:
pattern = "utils_simple_tree*"
file_path = os.fsdecode(pathlib.PurePath(TEST_DATA_PATH, "utils_simple_tree.py"))

expected: TestNode = {
expected: Node = {
"path": start_dir,
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"name": ".data",
"children": [
{
"name": "utils_simple_tree.py",
"type_": TestNodeTypeEnum.file,
"type_": NodeTypeEnum.file,
"path": file_path,
"children": [
{
"name": "TreeOne",
"path": file_path,
"type_": TestNodeTypeEnum.class_,
"type_": NodeTypeEnum.class_,
"children": [
{
"name": "test_one",
"path": file_path,
"type_": TestNodeTypeEnum.test,
"type_": NodeTypeEnum.test,
"lineno": "13",
"id_": file_path + "\\" + "TreeOne" + "\\" + "test_one",
"runID": "utils_simple_tree.TreeOne.test_one",
},
{
"name": "test_two",
"path": file_path,
"type_": TestNodeTypeEnum.test,
"type_": NodeTypeEnum.test,
"lineno": "16",
"id_": file_path + "\\" + "TreeOne" + "\\" + "test_two",
"runID": "utils_simple_tree.TreeOne.test_two",
Expand Down Expand Up @@ -230,33 +230,33 @@ def test_build_decorated_tree() -> None:
pattern = "utils_decorated_tree*"
file_path = os.fsdecode(pathlib.PurePath(TEST_DATA_PATH, "utils_decorated_tree.py"))

expected: TestNode = {
expected: Node = {
"path": start_dir,
"type_": TestNodeTypeEnum.folder,
"type_": NodeTypeEnum.folder,
"name": ".data",
"children": [
{
"name": "utils_decorated_tree.py",
"type_": TestNodeTypeEnum.file,
"type_": NodeTypeEnum.file,
"path": file_path,
"children": [
{
"name": "TreeOne",
"path": file_path,
"type_": TestNodeTypeEnum.class_,
"type_": NodeTypeEnum.class_,
"children": [
{
"name": "test_one",
"path": file_path,
"type_": TestNodeTypeEnum.test,
"type_": NodeTypeEnum.test,
"lineno": "24",
"id_": file_path + "\\" + "TreeOne" + "\\" + "test_one",
"runID": "utils_decorated_tree.TreeOne.test_one",
},
{
"name": "test_two",
"path": file_path,
"type_": TestNodeTypeEnum.test,
"type_": NodeTypeEnum.test,
"lineno": "28",
"id_": file_path + "\\" + "TreeOne" + "\\" + "test_two",
"runID": "utils_decorated_tree.TreeOne.test_two",
Expand Down